lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Deb Lucene <>
Subject Multi field search with values
Date Wed, 14 Mar 2012 15:32:39 GMT
Hi Group,

I am working on a Lucene search solution for multiple fields. So far, if
the fields are of string type I am having no difficulties in retrieving
using the MultiFieldQueryParser. For example, my indexing and searching
logic look like this -

- I am indexing a corpus on the content of the documents and some keywords
of the documents.

String doc = getText(id) ;
List<String> keywords = getKeywords(doc);
 document.add(new Field("content", doc, Field.Store.NO,Field.Index.ANALYZED,
for ( String keyword : keywords )
    document.add(new Field("keyword", keyword, Field.Store.NO,
Field.Index.ANALYZED, Field.TermVector.YES));
I am searching over the indexes using some query text and predefined
searching :
String queryText = getQuery();
String keyword = getKeyword();
 BooleanClause.Occur[] flags =
 Query query = MultiFieldQueryParser.parse(Version.LUCENE_33, new String[]
{queryText, keyword},
                 new String[]{"content","keywords"}, flags, stAnalyzer);
[stAnalyzer is the standard analyzer]

 TopDocs hits =, 20);


This code is working fine. But now suppose I add one more field (a
"threshold" set on some prior calculation) which is of numeric type.
NumericField field = new NumericField("threshold") ;

Now can I search over multiple fields using the "string" type (i.e. content
and keywords) with the "double" type (i.e. the threshold)?
I am particularly looking for a query such as -
query - "some content" and "some keywords" and threshold > 0.5.

I surmise I need to use the "numeric field search" technique but not sure
how to add the functionality in MultiFieldQueryParser.

Thanks in advance,

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message