Facebook
From Flying Guinea Pig, 3 Years ago, written in Plain Text.
This paste is a reply to Untitled from Gray Coyote - go back
Embed
Viewing differences between Untitled and Re: Untitled
{
curl --location --request POST '192.168.36.90/search' \
--header 'Content-Type: application/json' \
--data-raw '{
    "from": 0,
    "size": 24,
    "query": {
        "function_score": {
            "boost_mode": "replace",
            "functions": [
                {
                    "script_score": {
                        "params": {
                            "factor": 1.1,
                            "now": 1596725731
                        },
                        "script": [
                            "factor * (1 + (10-log(1 + 0.00024 * abs(now - doc['__updated_at'].doc['\''__updated_at'\''].value))))"
                        ]
                    }
                },
                {
                    "script_score": {
                        "params": {
                            "factor": 1.2
                        },
                        "script": [
                            "factor * log(1 + 0.06 * doc['price'].doc['\''price'\''].value)"
                        ]
                    }
                },
                {
                    "script_score": {
                        "params": {
                            "factor": 1.05
                        },
                        "script": [
                            "factor * (10 - log(1 + 37 * doc['ship_price'].doc['\''ship_price'\''].value))"
                        ]
                    }
                },
                {
                    "script_score": {
                        "params": {
                            "factor": 1.2
                        },
                        "script": [
                            "factor * log(1 + 25 * doc['sell_count'].doc['\''sell_count'\''].value)"
                        ]
                    }
                },
                {
                    "script_score": {
                        "params": {
                            "factor": 1.2
                        },
                        "script": [
                            "factor * log(1 + 0.001 * doc['stock'].doc['\''stock'\''].value)"
                        ]
                    }
                },
                {
                    "script_score": {
                        "params": {
                            "factor": 2
                        },
                        "script": [
                            "factor * doc['discount'].doc['\''discount'\''].value / 10"
                        ]
                    }
                },
                {
                    "script_score": {
                        "script": [
                            "-1 * (1000 * sqrt(doc['evo_category.id'].sqrt(doc['\''evo_category.id'\''].value))"
                        ]
                    }
                },
                {
                    "script_score": {
                        "script": [
                            "_score"
                        ]
                    }
                }
            ],
            "query": {
                "filtered": {
                    "filter": {
                        "bool": {
                            "must": [
                                {
                                    "term": {
                                        "shop_active": true
                                    }
                                },
                                {
                                    "term": {
                                        "active": true
                                    }
                                },
                                {
                                    "range": {
                                        "price": {
                                            "from": 0.99
                                        }
                                    }
                                },
                                {
                                    "range": {
                                        "stock": {
                                            "from": 1
                                        }
                                    }
                                },
                                {
                                    "range": {
                                        "evo_category.id": {
                                            "gt": 0
                                        }
                                    }
                                }
                            ],
                            "must_not": [
                                {
                                    "term": {
                                        "image_passive": true
                                    }
                                }
                            ]
                        }
                    },
                    "query": {
                        "bool": {
                            "should": [
                                {
                                    "match": {
                                        "name": "mayk ayakkabı"
                                    }
                                }
                            ],
                            "minimum_should_match": "100%"
                        }
                    }
                }
            },
            "score_mode": "avg"
        }
    },
    "sort": [
        {
            "_score": {
                "order": "desc"
            }
        }
    ],
    "aggs": {
        "attributes": {
            "aggs": {
                "attribute_values": {
                    "terms": {
                        "field": "evo_attributes.values.key_value"
                    }
                }
            },
            "terms": {
                "field": "evo_attributes.key_value"
            }
        },
        "category": {
            "terms": {
                "order": {
                    "_term": "asc"
                },
                "script": "doc['evo_category.breadcrumb_url_text']."doc['\''evo_category.breadcrumb_url_text'\''].value + '||' '\''||'\'' doc['evo_category.breadcrumb_text'].doc['\''evo_category.breadcrumb_text'\''].value",
                "size": 500
            }
        }
    }
}}'