query must match 2 fields exactly, don't analyze query must match 2 fields exactly, don't analyze elasticsearch elasticsearch

query must match 2 fields exactly, don't analyze


You can use scripting for this purpose. You would have to directly access the JSON you have stored with _source. Try following query

{  "query": {    "bool": {      "filter": {        "script": {          "script": {                "inline" : "_source.email==param1 && _source.password==param2",                "params" : {                    "param1" : "erik.landvall@example.com",                    "param2" : "bb3810356e9b60cf6"                }            }        }      }    }  }}

You would need to enable dynamic scripting. Add script.inline: on to your yml file and restart the node.

If this kind of query is fairly regular then It would be much better to reindex the data as others have suggested in the comments.


Its not possible to turn on/off analyzed or not, the way to do it to "transform" your field to analysis you need by using fields.

curl -XPUT 'localhost:9200/my_index?pretty' -d'{  "mappings": {    "my_type": {      "properties": {        "city": {          "type": "string",          "fields": {            "raw": {               "type":  "string",              "index": "not_analyzed"            }          }        }      }    }  }}'curl -XPUT 'localhost:9200/my_index/my_type/1?pretty' -d'{  "city": "New York"}'curl -XPUT 'localhost:9200/my_index/my_type/2?pretty' -d'{  "city": "York"}'curl -XGET 'localhost:9200/my_index/_search?pretty' -d'{  "query": {    "match": {      "city": "york"     }  },  "sort": {    "city.raw": "asc"   },  "aggs": {    "Cities": {      "terms": {        "field": "city.raw"       }    }  }

}'