lucenenet-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Omri Suissa <omri.sui...@diffdoof.com>
Subject Unexpected MultiFieldQueryParser result
Date Wed, 06 Feb 2013 10:41:48 GMT
Hi,

I'm using MultiFieldQueryParser to allow advance search in my application.

In some cases the user don't send the fields names and in some cases the
user send them.

In this case the user sent the following query:

(((name:10th AND name:10th) AND (name:10th AND name:10th) AND name:10th AND
name:10th) AND name:10th)

As you can see all the conditions are the same (name:10th).

My code looks like this:

MultiFieldQueryParser queryParser = new MultiFieldQueryParser
(Lucene.Net.Util.Version.LUCENE_30, fields, analyzer, boosts);



queryParser.AllowLeadingWildcard = true;



try

{

objQuery = queryParser.Parse(realQuery);

return objQuery;

}

catch (ParseException pe)

{

return null;

}



Where the [fields] variable is a list of default fields if the user didn't
send fields (not relevant in this case), the [analyzer] is
StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30) and some default boosts
(also not relevant in this case).

The result I got back is:

+(+(+(((name:"name 10th" +(((name:10th AND name:"name 10th ? name 10th")
+(+(((name:10th AND name:10th) AND (name:"name 10th ? name 10th ? name
10th" +(((name:10th AND name:10th) AND (name:10th AND name:"name 10th ?
name 10th ? name 10th ? name 10th") +(((name:10th AND name:10th) AND
(name:10th AND name:10th) AND name:"name 10th ? name 10th ? name 10th ?
name 10th ? name 10th" +(((name:10th AND name:10th) AND (name:10th AND
name:10th) AND name:10th AND name:"name 10th ? name 10th ? name 10th ? name
10th ? name 10th ? name 10th") +(((name:10th AND name:10th) AND (name:10th
AND name:10th) AND name:10th AND name:10th) AND name:"name 10th ? name 10th
? name 10th ? name 10th ? name 10th ? name 10th ? name 10th"

As you can see this is not what I was expected. The query search for
different things:

-          name:10th

-          name:"name 10th ? name 10th"

-          name:"name 10th ? name 10th ? name 10th"

-          name:"name 10th ? name 10th ? name 10th ? name 10th"

-          and so on…

Why is that? the way I see it, the user sent the same condition over and
over again with some brackets and ANDs between them that should not effect
a thing…

If this was an "IF" condition in C# is was just like saying "if
(name.Contains("10th") ==  true)".



Thanks,

Omri

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