Christian Hubinger
Christian Hubinger

Reputation: 121

Lucene.Net Query Parser/Index bug?

We are using Lucene.Net (2.3.2.1) with NHibernate.Search in our product and i found a very strange behaviour concerning my queries. Here is the Debug output from my thwo tests showing the input query and on the second line what the query parser generates, using the StandardAnalyser:

Test 1 (failing)

LastName:* AND IdentityType:A 
LastName:*

vs. Test 2 (working)

LastName:* AND IdentityType:F 
+LastName:* +IdentityType:f

As you can see the only difference is "A" vs. "F" - i played arround and could reproduce the same issue using "AN" "AS" "AND" - casing does not matter, but all other terms worked, i had the AND keyword in mind so i tired with "O" "OR" but those two are working.

For me that looked like an issue with the Query Parser... but now i also took a deeper look in my generated Index and well all Entities using an "A" in the IndentityType filed are not indexed!

I'd be thankful for any help or hints concerning that issue.

kind regards, Chris

Upvotes: 0

Views: 250

Answers (1)

Adrian Conlon
Adrian Conlon

Reputation: 3941

The StandardAnalyzer has a list of stop words it uses when analyzing text. The "A" is being removed by this.

Try using a per field analyzer wrapper, together with a different analyzer for your IndentityType field.

On a more administrative note, you'd have probably received at quicker answer if this question were tagged "Lucene" instead of just "Lucene.net"...

Good luck,

Upvotes: 2

Related Questions