lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurent Hoss <>
Subject "Field Grouping" query restrained to same field on a 'multi'-field'
Date Tue, 08 Aug 2006 16:25:14 GMT

Suppose having an Index containing Lucene documents, having multiple 
fields (equally) named 'paragraph'.
Now I want to make a "Field Grouping" query (described in: )
 "paragraph:( word1 AND word2 )"
retrieving only documents where the terms word1,word2 appear in the SAME 
'paragraph' Field (and not word1 in one 'paragraph' field, and word2 
possibly in another 'paragraph' field in this doc).
AFAIK right now this query is equivalent to query
"paragraph:word1 AND paragraph:word2", which makes sense of course.

Therefor to enable the behaviour I'm looking for, I'm thinking about 
modifying the QueryParser to support some syntactic flag like '#' in:  
paragraph#:( word1 AND word2 ).
This should generally work for  a query : paragraph#:( $subquery ) , 
where $subquery would be restrained to the same 'paragraph' field as 
explained above.

However the main question is whether adding such an option would be 
feasible in Lucene (Core, Searcher?)
without incrementing algorithmic complexity ... and is not too 
complicated to implement?

If yes I would be very happy to get some pointers in the right 
direction, like in which Classes this is done best.

PS: If this is not an option, we (unhappily) would have to live with 
following 'hack':
Each 'paragraph' is stored in a differently named field (by adding 
number) : paragraph1, paragraph2...
Other than the uglyness, this would have the big drawback that we need 
as many OR clauses as we set our maximum number of paragraphs to .
Simple,short query:
 paragraph: $query 
would have to be  exploded to:    
 (paragraph1: $query) OR (paragraph2: $query)  OR ... OR (paragraphN: 

PS2: Just saw following in the FAQ :
"How can I search over multiple fields? "
 >Parse your query using MultiFieldQueryParser 

But this seems to not help here, or did I overlook something ?

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

View raw message