We have code (using Lucene 2.4.1) that will build a query that looks like:

 

fielda:"ruz an"~2 OR fieldb:"ruz an"~2 OR fieldc:"ruz an"~2

 

When passed to a MultiFieldQueryParser and parsed it comes back looking
like:

 

fielda:"ruz an"~2 fieldb:"ruz an"~2 fieldc:ruz

 

It seems that whenever the input phrase has a stop word in it, fieldc
doesn't keep the phrase intact.   If there is no stop word then it works as
expected and just removes the OR's.

 

The code is pretty simple

 

MultiFieldQueryParser parser = new MultiFieldQueryParser(getCrossfields(),
new MyAnalyzer());

parser.setDefaultOperator(QueryParser.Operator.AND);

            

Query crossFieldQuery = parser.parse(searchExpression);

 

getCrossFields returns a String[] of all the fields we want to look at.
MyAnalyzer is a pretty basic analyzer which adds a filter to remove
diacritics.   searchExpression is the whatever is coming into the search
function, in this case the pre-built query.

 

 

 

Is there a reason that the parse method decides to change the last field
instead of keeping the phrase intact?

Reply via email to