0
GET taps/_search
{
  "query": {
    "bool": {
      "should": [
        { "match": { "test_card": "ZE-S-180x4" }},
        { "match": { "pf": "ZX480" }},
        { "match": { "fpc": "AEZE 3D MP+6E" }},
        { "match": { "rpd": "32" }},
        { "match": { "rel": "25" }},
        { "match": { "rel_type": "1234_daily" }}
      ]
    }
}
}

fpc is not getting as single word match, it's querying as 3 words and getting more results.

venkat
  • 33
  • 5

1 Answers1

1

In order for ES to ignore spaces, what if you have the plus signs between the string values in the below match:

{ "match": { "fpc": "AEZE","3D","MP+6E" }}

OR

when you're creating the mapping for the fields, you can have the fields which you need to match exactly as below:

curl -XPUT localhost:9200/my_index -d '{
   "mappings": {
       "my_type": {
           "properties": {
               "instruments": {
                   "type": "string",
                   "index": "not_analyzed" <--- you need to have this for the field to get tokenized
               }
           }
       }
   }
}'

Then of course you could go on match the string with white spaces.

Ref & this SO could be helpful.

Community
  • 1
  • 1
Kulasangar
  • 9,046
  • 5
  • 51
  • 82
  • Thanks for your reply. The value in database will be with spaces "AEZE 3D MP+6E"only. So can i get right results. – venkat Nov 30 '16 at 09:58
  • Did you try checking your result by changing your fpc match to either one of the above in the answer? – Kulasangar Nov 30 '16 at 10:00
  • Sorry, Our server is down as of now. So asking before it comes up. I will run and get back to you. If you have idea please get back. – venkat Nov 30 '16 at 10:01
  • @venkat any effects after the changes ? – Kulasangar Dec 01 '16 at 04:03
  • No, It is throwing syntax error. { "match": { "fpc_type": "MPC5E"+"3D"+"24XGE+6XLGE" }}, Error below "reason": "Unexpected character ('+' (code 43)): was expecting comma to separate Object entries\n at [Source: [B@1c6dfecf; line: 5, column: 43]" I am running command in sense – venkat Dec 05 '16 at 06:17
  • @venkat what if you remove the + and insert a comma `,` instead of + ? I've updated the answer. – Kulasangar Dec 06 '16 at 08:53