elasticsearch multi_match的一個小坑

博客原文
安利一篇我翻譯的國外大牛的神經網絡入門文章

最近在使用elasticsearch的multi_match搜索時候,使用下面的body對一個字段下的所有字段進行遞歸搜索,但是當這些子字段出現數值類型的時候,就會報異常了,具體討論可以參考
https://github.com/elastic/elasticsearch/issues/3975
解決方法是加入lenient字段,參考下面的body

{
    "query": {
        "bool": {
            "should": [
                {
                    "match": {
                        "user_id": {
                            "query": "qwe",
                            "boost": 5
                        }
                    }
                },
                {
                    "multi_match": {
                        "query": "qwer",
                        "lenient": "true",  --ignore values that don't fit specific fields
                        "fields": [
                            "device_brand",
                            "device_manufacturer",
                            "user_properties.*" ---表明搜索此字段下的所有子字段
                        ]
                    }
                },
                {
                    "query_string": {
                        "query": "*qwe*",
                        "default_field": "user_id",
                        "boost": 5
                    }
                }
            ]
        }
    },
    "size": 10,
    "sort": ["_score",{"session_id": "asc"}]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章