Sort order of display when searching
-
I make the api query to the elastic search server through json as follows .
{ "from": 0, "size": 5, "sort": [ { "_score": { "order": "desc" } } ], "query": { "function_score": { "query": { "bool": { "should": [ { "bool": { "must": [ { "bool": { "should": [ { "multi_match": { "query": "con", "type": "phrase", "fields": [ "post_title^5", "meta._sku.value^3", "terms.product_cat.name^2", "terms.ep_custom_result.name^9999" ], "boost": 3 } }, { "multi_match": { "query": "", "fields": [ "post_title^5", "meta._sku.value^3", "terms.product_cat.name^2", "post_title.suggest^1", "term_suggest^1" ], "boost": 1, "fuzziness": "auto", "operator": "and" } }, { "multi_match": { "query": "", "type": "cross_fields", "fields": [ "post_title^1", "meta._sku.value^1", "terms.product_cat.name^1", "terms.ep_custom_result.name^1" ], "boost": 1, "analyzer": "standard", "tie_breaker": 0.5, "operator": "and" } } ] } } ], "filter": [ { "match": { "post_type.raw": "product" } } ] } } ] } }, "functions": [ { "exp": { "post_date_gmt": { "scale": "14d", "decay": 0.25, "offset": "7d" } } }, { "weight": 0.001 } ], "score_mode": "sum", "boost_mode": "multiply" } }, "post_filter": { "bool": { "must": [ { "bool": { "must_not": [ { "terms": { "terms.product_visibility.term_taxonomy_id": [ 6 ] } } ] } }, { "term": { "post_author.id": 3 } }, { "terms": { "post_type.raw": [ "product" ] } }, { "terms": { "post_status": [ "publish", "wcctdisabled", "acf-disabled" ] } } ] } }, "aggs": { "terms": { "filter": { "bool": { "must": [ { "bool": { "must_not": [ { "terms": { "terms.product_visibility.term_taxonomy_id": [ 6 ] } } ] } }, { "term": { "post_author.id": 3 } }, { "terms": { "post_type.raw": [ "product" ] } }, { "terms": { "post_status": [ "publish", "wcctdisabled", "acf-disabled" ] } } ] } }, "aggs": { "category": { "terms": { "size": 10000, "field": "terms.category.slug" } }, "post_tag": { "terms": { "size": 10000, "field": "terms.post_tag.slug" } }, "post_format": { "terms": { "size": 10000, "field": "terms.post_format.slug" } }, "product_cat": { "terms": { "size": 10000, "field": "terms.product_cat.slug" } }, "product_tag": { "terms": { "size": 10000, "field": "terms.product_tag.slug" } }, "product_shipping_class": { "terms": { "size": 10000, "field": "terms.product_shipping_class.slug" } }, "store_category": { "terms": { "size": 10000, "field": "terms.store_category.slug" } }, "ep_custom_result": { "terms": { "size": 10000, "field": "terms.ep_custom_result.slug" } }, "pa_color": { "terms": { "size": 10000, "field": "terms.pa_color.slug" } }, "pa_flash-sale": { "terms": { "size": 10000, "field": "terms.pa_flash-sale.slug" } } } } } }
I see it’s sorting by key _score descending, I need it to change to pagaeview descending, how can I change that. I’ve noticed that the results that return each product always have a pageview in the following structure.
{ "_index": "p1webnewinfo-post-1", "_type": "_doc", "_id": "209589", "_score": 0.07046076, "_source": { "post_id": 209589, "ID": 209589, "post_author": { "raw": "megahoangmai", "login": "megahoangmai", "display_name": "MM Mega Market Hoàng Mai", "id": 3 }, "post_date": "2021-06-23 22:35:32", "post_date_gmt": "2021-06-23 15:35:32", "post_title": "V?t ta nguyên con", "post_excerpt": "<p style='font-style:italic' class='product-short-description'>* S? l??ng ??t hàng c?a quy khách có th? chênh l?ch v?i th?c t?. (Nhan viên ch?m sóc khách hàng c?a Trung tam <b>MM Mega Market</b> s? liên h? xác nh?n v?i Quy khách tr??c khi giao hàng)</p>", "post_content_filtered": "", "post_content": "", "post_status": "publish", "post_name": "vit-ta-nguyen-con-11", "post_modified": "2021-07-28 17:48:42", "post_modified_gmt": "2021-07-28 10:48:42", "post_parent": 0, "post_type": "product", "post_mime_type": "", "permalink": "https://p1.webnew.info/san-pham/mm-hoang-mai/vit-ta-nguyen-con-11/", "terms": { "product_cat": [ { "term_id": 163, "slug": "thit-en", "name": "Th?t", "parent": 160, "term_taxonomy_id": 163, "term_order": 0, "facet":"{\"term_id\":163,\"slug\":\"thit-en\",\"name\":\"Th\?t\",\"parent\":160,\"term_taxonomy_id\":163,\"term_order\":0}" }, { "term_id": 160, "slug": "thuc-pham-tuoi-song", "name": "Th?c ph?m t??i s?ng", "parent": 0, "term_taxonomy_id": 160, "term_order": 0, "facet":"{\"term_id\":160,\"slug\":\"thuc-pham-tuoi-song\",\"name\":\"Th\?c ph\?m t\?\?i s\?ng\",\"parent\":0,\"term_taxonomy_id\":160,\"term_order\":0}" } ], "product_tag": [ { "term_id": 461, "slug": "product_unit_step_0-5", "name": "product_unit_step_0.5", "parent": 0, "term_taxonomy_id": 461, "term_order": 0, "facet": "{\"term_id\":461,\"slug\":\"product_unit_step_0-5\",\"name\":\"product_unit_step_0.5\",\"parent\":0,\"term_taxonomy_id\":461,\"term_order\":0}" } ], "product_type": [ { "term_id": 2, "slug": "simple", "name": "simple", "parent": 0, "term_taxonomy_id": 2, "term_order": 0, "facet": "{\"term_id\":2,\"slug\":\"simple\",\"name\":\"simple\",\"parent\":0,\"term_taxonomy_id\":2,\"term_order\":0}" } ] }, "meta": { "_sku": [ { "value": "14-154157", "raw": "14-154157", "boolean": false, "date": "1970-01-01", "datetime": "1970-01-01 00:00:01", "time": "00:00:01" } ], "_regular_price": [ { "value": "87900", "raw": "87900", "long": 87900, "double": 87900, "boolean": false, "date": "1970-01-01", "datetime": "1970-01-01 00:00:01", "time": "00:00:01" } ], "_sale_price": [ { "value": "", "raw": "", "boolean": false } ], "total_sales": [ { "value": "9", "raw": "9", "long": 9, "double": 9, "boolean": false, "date": "1970-01-01", "datetime": "1970-01-01 00:00:01", "time": "00:00:01" } ], "_tax_status": [ { "value": "taxable", "raw": "taxable", "boolean": false, "date": "1970-01-01", "datetime": "1970-01-01 00:00:01", "time": "00:00:01" } ], "_tax_class": [ { "value": "", "raw": "", "boolean": false } ], "_manage_stock": [ { "value": "no", "raw": "no", "boolean": false, "date": "1970-01-01", "datetime": "1970-01-01 00:00:01", "time": "00:00:01" } ], "_backorders": [ { "value": "no", "raw": "no", "boolean": false, "date": "1970-01-01", "datetime": "1970-01-01 00:00:01", "time": "00:00:01" } ], "_sold_individually": [ { "value": "no", "raw": "no", "boolean": false, "date": "1970-01-01", "datetime": "1970-01-01 00:00:01", "time": "00:00:01" } ], "_virtual": [ { "value": "no", "raw": "no", "boolean": false, "date": "1970-01-01", "datetime": "1970-01-01 00:00:01", "time": "00:00:01" } ], "_downloadable": [ { "value": "no", "raw": "no", "boolean": false, "date": "1970-01-01", "datetime": "1970-01-01 00:00:01", "time": "00:00:01" } ], "_thumbnail_id": [ { "value": "208244", "raw": "208244", "long": 208244, "double": 208244, "boolean": false, "date": "1970-01-01", "datetime": "1970-01-01 00:00:01", "time": "00:00:01" } ], "_stock": [ { "value": null, "raw": null, "boolean": false } ], "_stock_status": [ { "value": "instock", "raw": "instock", "boolean": false, "date": "1970-01-01", "datetime": "1970-01-01 00:00:01", "time": "00:00:01" } ], "_wc_average_rating": [ { "value": "0", "raw": "0", "long": 0, "double": 0, "boolean": false } ], "_product_version": [ { "value": "4.0.2", "raw": "4.0.2", "boolean": false, "date": "2022-05-19", "datetime": "2022-05-19 04:00:02", "time": "04:00:02" } ], "_price": [ { "value": "87900", "raw": "87900", "long": 87900, "double": 87900, "boolean": false, "date": "1970-01-01", "datetime": "1970-01-01 00:00:01", "time": "00:00:01" } ], "pageview": [ { "value": "9", "raw": "9", "long": 9, "double": 9, "boolean": false, "date": "1970-01-01", "datetime": "1970-01-01 00:00:01", "time": "00:00:01" } ] }, "date_terms": { "year": 2021, "month": 6, "week": 25, "dayofyear": 173, "day": 23, "dayofweek": 3, "dayofweek_iso": 3, "hour": 22, "minute": 35, "second": 32, "m": 202106 }, "comment_count": 0, "comment_status": "open", "ping_status": "closed", "menu_order": 0, "guid": "https://online.mmvietnam.com/san-pham/administrator/vit-ta-nguyen-con-11/", "thumbnail": { "ID": 208244, "src": "https://p1.webnew.info/wp-content/uploads/media/154157-300x300.jpg", "width": 300, "height": 300, "alt": "" }, "custom_filters": { "views_count": "views_count" }, "post_lang": "vi", "term_suggest": [ "Th?t", "Th?c ph?m t??i s?ng", "product_unit_step_0.5", "simple" ] } },
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Sort order of display when searching’ is closed to new replies.