0

I am writing query get all documents which has "am" or "pm" in their name, and my query goes like this: (sellerName:am pm).

Returned document as follows:

doc1:

  seller name:am
  city: bangalore 
  state:Kar
  country:In
  zip:560034

doc2:

          seller name:pm
          city: bang
          state:Kar
          country:In
          zip:560034

doc3:

      seller name: Ganesh
      city: bang
      state:Kar pm
      country:In
      zip:560034

First two documents are getting returned as we have am or pm in their name, My question is even though we don't have am or pm in the seller name of Doc3 still this is even getting as match. This is because we have pm in zip code if doc3.

I don't want this to be returned as a result. How can I do this? And why its matching with the Doc3, even though doc3 does not contain am or pm.

Thanks in advance.

786543214
  • 855
  • 4
  • 14
  • 29

2 Answers2

0

This is standard lucene query syntax.

sellerName:am pm translates to sellerName:am defaultField:pm. You're default field is probably an "all" field, or something like that, I would guess.

Your query should be: sellerName:(am pm)

femtoRgon
  • 32,893
  • 7
  • 60
  • 87
0

A very easy way to determine what query is being sent to Lucene is by sending debugQuery=true which tells you exactly how the query is parsed.

xmorera
  • 1,933
  • 3
  • 20
  • 35