【少女人妻的30天Elastic】Day 27 : App Search_API 介绍与应用_Search Settings

Aloha!又是我少女人妻 Uerica!这个连假又过了一场奇幻旅程,交了两个好朋友,心得是原来我们都很少真诚地诉说自己的感受,但人与人要拉近彼此的距离,除了真诚与真心敞开,别无他法了阿~

Search Settings

搜寻设定就是利用 API 的方式查询与更改与重设字词 Weights 、 Boosts 状态,以及设定与定义 raw 、 snippet 回传字元。

Show Settings

GET 请求显示 Engine 中资料栏位的 Weights 与 Boosts 的状态

GET /api/as/v1/engines/{ENGINE_NAME}/search_settings

需用 private key

curl -X GET '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/search_settings' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d ''

Response

{
    "search_fields": {
        "area": {
            "weight": 2
        },
        "action_rule": {
            "weight": 1
        },
        "place_name": {
            "weight": 3
        },
        "note": {
            "weight": 1
        },
        "address": {
            "weight": 1
        },
        "city": {
            "weight": 1
        },
        "bh": {
            "weight": 1
        },
        "url": {
            "weight": 1
        },
        "phone": {
            "weight": 1
        },
        "stay_fee": {
            "weight": 1
        },
        "place_type": {
            "weight": 1
        },
        "place_desc": {
            "weight": 1
        },
        "place_facility": {
            "weight": 1
        },
        "close": {
            "weight": 1
        },
        "open": {
            "weight": 1
        },
        "lat": {
            "weight": 1
        },
        "id": {
            "weight": 1
        }
    },
    "result_fields": {
        "area": {
            "raw": {}
        },
        "place_name": {
            "raw": {}
        },
        "note": {
            "raw": {}
        },
        "id": {
            "raw": {}
        },
        "phone": {
            "raw": {}
        },
        "place_desc": {
            "raw": {}
        }
    },
    "boosts": {}
}

Update Settings

PUT 更新 Engine 中资料栏位的 Weights 与 Boosts 的状态

PUT /api/as/v1/engines/{ENGINE_NAME}/search_settings
{
    "search_fields": {
        "area": {
            "weight": 4
        },
        "action_rule": {
            "weight": 1
        },
        "place_name": {
            "weight": 5
        },
        "note": {
            "weight": 1
        },
        "address": {
            "weight": 1
        },
        "city": {
            "weight": 4
        },
        "bh": {
            "weight": 1
        },
        "url": {
            "weight": 1
        },
        "phone": {
            "weight": 1
        },
        "stay_fee": {
            "weight": 1
        },
        "place_type": {
            "weight": 3
        },
        "place_desc": {
            "weight": 2
        },
        "place_facility": {
            "weight": 5
        },
        "close": {
            "weight": 1
        },
        "open": {
            "weight": 1
        },
        "lat": {
            "weight": 1
        },
        "id": {
            "weight": 1
        }
    },
    "result_fields": {
        "area": {
            "raw": {}
        },
        "place_name": {
            "raw": {}
        },
        "note": {
            "raw": {}
        },
        "id": {
            "raw": {}
        },
        "phone": {
            "raw": {}
        },
        "place_desc": {
            "snippet": {
            "size": 20,
            "fallback": true
        }
        }
    },
    "boosts": {
            "place_type": [
            {   
                "type": "value",
                "factor": 9.5,
                "value": [
                "true"
            ]
        }
        ]
    }
}

Reset Setting

POST 重设 Engine 中资料栏位的 Weights 与 Boosts 的状态

POST /api/as/v1/engines/{ENGINE_NAME}/search_settings/reset
curl -X POST '{API_Endpoint}/api/as/v1/engines/{ENGINE_NAME}/search_settings/reset' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxx' \
-d ''

感谢各位阅读,祝福大家都跟身边的人越来越亲近 :)


<<:  《DAY 29》天气 App 实作(二)

>>:  [D27] : 一个Queue+Docker在Local的实作(1/4)

DAY10 Line Messaging API 的各种讯息格式

传送文字 在设定回覆讯息的部分,如果是文字讯息的话,是这样写: events.message.typ...

【16】如果把图片从RGB转成HSV和灰阶再拿去训练会怎样

colab连结 普遍我们拿来训练的图片都是RGB,普遍都是机器学习的CNN层找到一些局部特徵来做分类...

Day 12 - Using List<T> to Store JSON Format Path with ASP.NET Web Forms C# 用强类型物件清单储存 JSON 格式的相簿图片路径

=x= 🌵 建立後台相簿管理并使用 JSON 格式储存多个图片的路径。 相簿管理功能介绍 : 📌 这...

[Day 14] Reverse 小入门

时间飞逝,已到第14天了 明天就一半ㄌ,好感动眼睛流汗 今天我们要干大事!!! 要来解 REVERS...

15.MYSQL搜寻'部分'字串

MYSQL中搜寻字元,除了用上一篇的 = 与 != 之外,还有一个更好用的语法,叫做 LIKE 和 ...