I’m trying to search through all indices on ElasticSearch, and only show the results which are an exact match for my query. I would specify a field, but all my indices have different field names for the same thing, so it would not work very well.
I’ve tried this query:
GET /_search
{
"query": {
"query_string": {
"query": "[email protected]",
"fields": ["*"]
}
}
}
This does work for searching through all fields, but it gets everything which contains “[email protected]” rather than only getting the results which have that exact string in any of the fields. Is there any way to make the query so it only gets the results which are an exact match to the query, rather than it returning any results which contains the query?
This is a sample of the result from the above query:
{
"took": 7941,
"timed_out": false,
"_shards": {
"total": 13,
"successful": 13,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 4,
"relation": "eq"
},
"max_score": 16.785738,
"hits": [
{
"_index": "[REDACTED]",
"_id": "g1qD0o8BspIBF6pui4tY",
"_score": 16.785738,
"_source": {
"email": "[email protected]",
"password": "[REDACTED]"
}
},
{
"_index": "[REDACTED]",
"_id": "EQ_G2o8Bscm15FIBl7mN",
"_score": 12.5678215,
"_source": {
"email": "[email protected]",
"display_name": "[REDACTED]",
"username": "[REDACTED]",
"followers": 1,
"created_at": "Wed Dec 05 08:01:45 +0000 2012"
}
},
{
"_index": "[REDACTED]",
"_id": "k7bG048BspIBF6puMOJK",
"_score": 10.896135,
"_source": {
"id": 114820652,
"username": "[REDACTED]",
"email": "[email protected]",
"password": null,
"ip": "[REDACTED]"
}
}
]
}
}
almighty is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.