I have an indexed field 'properties.language' with the value 'en sv'. This field has a multi_field mapping that consists of two fields, one analyzed (name 'language'), and one that is not_analyzed (name '_exact').
How do I issue a single search query without having to query both 'properties.language' and 'properties.language._exact'?
Edit:
Here is my configuration:
Indexed data:
{
"_index": "51ded0be98035",
"_type": "user",
"_id": "WUzwcwhTRbKur7J5ZY_hgA",
"_version": 1,
"_score": 1,
"_source": {
"properties": {
"language":"en sv"
}
}
}
Mapping for type 'user':
{
"user": {
"properties": {
"properties": {
"properties": {
"language": {
"type": "multi_field",
"fields": {
"language": {
"type": "string",
"analyzer": "standard",
"index": "analyzed"
},
"_exact": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
}
Search query:
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [{
"or": [{
"term": {
"properties.language": "en sv"
}
}, {
"term": {
"properties.language._exact": "en sv"
}
}]
}]
}
}
}
}
}
en sv
then? If so, then you only need to do a must match on your_exact
field. Although, I'm guessing that's not the issue you're having... I'm confused what you're actually trying to accomplish in your query. – James Addison