hi, i am new to elasticsearch, trying to implement it in place of mysql full text search.
i am confused in these 3 queries as which one is better over another and why ?
i am trying to to use filter and without use filter.
$params['body']['query']['bool']['must'][]['match']['category'] = 500;
$params['body']['query']['bool']['filter']['range']['category']['gte'] = 500;
$params['body']['query']['bool']['filter']['range']['category']['lte'] = 500;
$params['body']['query']['bool']['filter']['term']['category'] = 500;
all above queries gives same results set.
1 not using any filter , first one becomes [time taken : 20]
Array
(
[index] => dataset
[type] => content
[body] => Array
(
[query] => Array
(
[bool] => Array
(
[must] => Array
(
[0] => Array
(
[match] => Array
(
[title] => mother
)
)
[1] => Array
(
[match] => Array
(
[category] => 500
)
)
)
)
)
[sort] => Array
(
[uploaders] => Array
(
[order] => desc
)
)
)
)
2 using range filter, second query becomes [time taken : 8]
Array
(
[index] => dataset
[type] => content
[body] => Array
(
[query] => Array
(
[bool] => Array
(
[must] => Array
(
[0] => Array
(
[match] => Array
(
[title] => mother
)
)
)
[filter] => Array
(
[range] => Array
(
[category] => Array
(
[gte] => 500
[lte] => 500
)
)
)
)
)
[sort] => Array
(
[uploaders] => Array
(
[order] => desc
)
)
)
)
3 using term filter , 3rd query becomes [time taken : 21]
Array
(
[index] => dataset
[type] => content
[body] => Array
(
[query] => Array
(
[bool] => Array
(
[must] => Array
(
[0] => Array
(
[match] => Array
(
[title] => mother
)
)
)
[filter] => Array
(
[term] => Array
(
[category] => 500
)
)
)
)
[sort] => Array
(
[uploaders] => Array
(
[order] => desc
)
)
)
)
Thanks for your time.
my mapping is like this
"mappings": {
"content": {
"properties": {
"title":{
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
},
"tags": { "type": "text" },
"category": { "type": "short" },
"sub_category": { "type": "short" },
"size": { "type": "long" },
"uploaders": { "type": "integer" },
"donwloader": { "type": "integer" },
"upload_date": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"uploader":{
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
}
}
}
}
i have around 4.6 million documents, on dedicated server with 128 gb RAM and dual xeon cpu, only runnning elasticsearch , mysql, nginx,php