Hello everyone,
I have a problem with keyword query.
I want to filter categoryProperties by key and value.
key is"color" and value contains "mavi"
But it gives me document it contains key is "color" and value contains "Beyaz"
Do you have any idea why?
REQUEST
{
"from": 0,
"size": 50,
"sort": [{
"id": {
"order": "asc"
}
}],
"query": {
"bool": {
"must": [{
"nested": {
"query": {
"bool": {
"must": [{
"nested": {
"query": {
"bool": {
"should": [{
"bool": {
"must_not": [{
"term": {
"searchQuery.categoryProperties.key": {
"value": "color"
}
}
}]
}
},
{
"bool": {
"must": [{
"term": {
"searchQuery.categoryProperties.key": {
"value": "color"
}
}
},
{
"nested": {
"query": {
"term": {
"searchQuery.categoryProperties.values.value": {
"value": "Mavi"
}
}
},
"path": "searchQuery.categoryProperties.values"
}
}]
}
}]
}
},
"path": "searchQuery.categoryProperties"
}
}]
}
},
"path": "searchQuery"
}
}]
}
}
}
RESPONSE
{
"took": 32,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": null,
"hits": [{
"_index": "favoritesearchsearchmodelindex_2",
"_type": "favoritesearchsearchmodel",
"_id": "76175",
"_score": null,
"_source": {
"searchQuery": {
"categoryProperties": [{
"key": "maxkm",
"values": [{
"value": "1200000"
}],
"intValue": 1200000
},
{
"key": "color",
"values": [{
"value": "Beyaz"
}]
},
{
"key": "gear",
"values": [{
"value": "Otomatik"
}]
},
{
"key": "category",
"values": [{
"value": "26553"
}],
"intValue": 26553
}],
"hasPhoto": false,
"currency": 0,
"city": [],
"category": [{
"id": 26553
}]
}
}
}]
}
}
MAPPING
{
"favoritesearchsearchmodelindex_2": {
"mappings": {
"favoritesearchsearchmodel": {
"properties": {
"searchQuery": {
"type": "nested",
"properties": {
"categoryProperties": {
"type": "nested",
"properties": {
"intValue": {
"type": "integer"
},
"key": {
"type": "keyword"
},
"values": {
"type": "nested",
"properties": {
"value": {
"type": "keyword"
}
}
}
}
}
}
}
}
}
}
}
}