0

I have following code for Lucene .Net search:

enter image description here

If I use query like:

AccountId:1 AND CompanyId:1 AND CreatedOn:[636288660000000000 TO 636315443990000000] AND AuditProperties.FriendlyName.NewValue:CustomerId|235

It works fine with exact match with CustomerId = 235.

However, if I try to search for a wildcard match like for example:

AccountId:1 AND CompanyId:1 AND CreatedOn:[636288660000000000 TO 636315443990000000] AND AuditProperties.FriendlyName.NewValue:CustomerId|*235*

it doesn't fetch me any results. I think it is still going for an exact match with value "*235*" Am I missing anything here?

Thanks!

Deepak Agarwal
  • 458
  • 1
  • 4
  • 18
  • This query should work fine. Can you debug and show us the value of parser.Parse(query)? Can you replicate in Luke? Also, the single pipe (|) is a bit iffy, as Luke (at least v4.0) considers single pipe a logical OR. – christofr Jun 04 '17 at 12:03

1 Answers1

1

As per the QueryParser syntax documentation, the character | is not supported. However, it is not very clear whether you intended it to be a logical OR or a literal character.

Logical OR

The correct syntax for logical OR is either CustomerId OR *235*, CustomerId *235* or CustomerId||*235*.

Also, if this is meant to be a logical OR, you have to allow for a leading wildcard character as pointed out in Howto perform a 'contains' search rather than 'starts with' using Lucene.Net.

parser.AllowLeadingWildcard = true;

Literal |

To search for a literal pipe character, you should escape the character so the parser doesn't confuse it with a logical OR.

CustomerId\|*235*
NightOwl888
  • 55,572
  • 24
  • 139
  • 212