lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "G.Long" <>
Subject problem with a query
Date Wed, 07 Sep 2011 09:47:33 GMT
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 =;
PerFieldAnalyzerWrapper pfaWrapper = getPerfFieldAnalyzer();
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_31, 
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);, 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 :)


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message