Skip to content

Instantly share code, notes, and snippets.

@perryholden
Last active October 11, 2023 15:09
Show Gist options
  • Save perryholden/4771bcdd0d8130f29220b0774a834e7c to your computer and use it in GitHub Desktop.
Save perryholden/4771bcdd0d8130f29220b0774a834e7c to your computer and use it in GitHub Desktop.
Debug Elasticsearch Results
\Magento\Elasticsearch7\SearchAdapter\Adapter::query (This kicks off the entire request)
\Elasticsearch\Connections\Connection::performRequest line 210 (This is the formatted $body variable)
Take the serialized $body varable, then replace the -d argument with the contents:
curl -H 'Content-Type: application/json' -XPOST "http://elasticsearch:9200/magento2_product_1/_search?pretty" -d'{
"from": 0,
"size": 48,
"stored_fields": "_none_",
"docvalue_fields": [
"_id",
"_score"
],
"sort": [
{
"bestsellers": {
"order": "desc"
}
},
{
"reviews_count": {
"order": "desc"
}
}
],
"query": {
"bool": {
"must": [
{
"term": {
"category_ids": "104"
}
},
{
"terms": {
"visibility": [
"2",
"4"
]
}
}
]
}
}
}' -s
This queries all information about a specific product (determines what is held in Elasticsearch regarding this product)
curl -H 'Content-Type: application/json' -XPOST "http://elasticsearch:9200/magento2_product_1/_search?pretty" -d'{"query": {
"bool": {
"must": [{
"bool": {
"should": [{
"terms": {
"_id": ["28118"]
}
}, {
"match": {
"is_global": 0
}
}]
}
}]
}
}}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment