lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: problem with a query
Date Wed, 07 Sep 2011 11:15:55 GMT
Nothing really jumps out, but here's an idea:
Dump query.toString() and see if it's what you
expect as the parsed query.

And make absolutely sure that the directory you open
in your Java code is the same one you open in Luke. You'd
be amazed how much time I've spent tracking down
mistakes like that <G>.

Best
Erick

"It's not the things you don't know that'll kill you, it's the things
you *do* know that aren't true".

On Wed, Sep 7, 2011 at 5:47 AM, G.Long <jdevgl@gmail.com> wrote:
> Hi :)
>
> I have a lucene index with fields analyzed with Keyword Analyzer. In my java
> program, I search for a document by creating a query with two boolean
> parameters like : +param1:"foo" +param2:"bar"
>
> The query return no result but If I run the same query with Luke, it returns
> the result I'm looking for :/
>
> I'm using the same method to initialyze the index writer and searcher :
>
> directory = FSDirectory.open(indexFolder);
> PerFieldAnalyzerWrapper pfaWrapper = getPerfFieldAnalyzer();
> IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_31,
> pfaWrapper);
> config.setOpenMode(OpenMode.CREATE_OR_APPEND);
> iwriter = new IndexWriter(directory, config);
> isearcher = new IndexSearcher(directory);
>
> (The default analyzer for PerFieldAnalyzer is KeywordAnalyzer. I'm using it
> because there are two fields in my index which use StandardAnalyzer but
> these are not the ones I'm using in my query)
>
> To create my query, I use the following code:
>
> Analyzer analyzer = new KeywordAnalyzer();
> QueryParser parser = new QueryParser(Version.LUCENE_31, key, analyzer);
> Query param = parser.parse(value);
> query.add(param, BooleanClause.Occur.MUST);
>
> And then the execution of my query:
>
> TopFieldCollector collector = TopFieldCollector.create(new
> Sort(SortField.FIELD_DOC), 200000, true, false, false, false);
> isearcher.search(query, collector);
> ScoreDoc[] hits = collector.topDocs().scoreDocs;
>
> Any ideas of why the query isn't returning anything although the params of
> the query correspond to an existing result?
>
> In Luke, I specify the Keyword Analyzer and it works.
>
> Thank you for your help :)
>
> Gary
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message