我們正在運行Elasticsearch 1.7(計劃很快升級),我試圖使用Analyze API來了解不同分析器的功能,但彈性搜索的結果並不是我期望。分析API不適用於Elasticsearch 1.7
如果我跑反對我們elasticsearch例如
GET _analyze
{
"analyzer": "stop",
"text": "Extremely good food! We had the happiest waiter and the crowd's always flowing!"
}
下面的查詢,我會得到這樣的結果
{
"tokens": [
{
"token": "analyzer",
"start_offset": 6,
"end_offset": 14,
"type": "<ALPHANUM>",
"position": 1
},
{
"token": "stop",
"start_offset": 18,
"end_offset": 22,
"type": "<ALPHANUM>",
"position": 2
},
{
"token": "text",
"start_offset": 30,
"end_offset": 34,
"type": "<ALPHANUM>",
"position": 3
},
{
"token": "extremely",
"start_offset": 38,
"end_offset": 47,
"type": "<ALPHANUM>",
"position": 4
},
{
"token": "good",
"start_offset": 48,
"end_offset": 52,
"type": "<ALPHANUM>",
"position": 5
},
{
"token": "food",
"start_offset": 53,
"end_offset": 57,
"type": "<ALPHANUM>",
"position": 6
},
{
"token": "we",
"start_offset": 59,
"end_offset": 61,
"type": "<ALPHANUM>",
"position": 7
},
{
"token": "had",
"start_offset": 62,
"end_offset": 65,
"type": "<ALPHANUM>",
"position": 8
},
{
"token": "the",
"start_offset": 66,
"end_offset": 69,
"type": "<ALPHANUM>",
"position": 9
},
{
"token": "happiest",
"start_offset": 70,
"end_offset": 78,
"type": "<ALPHANUM>",
"position": 10
},
{
"token": "waiter",
"start_offset": 79,
"end_offset": 85,
"type": "<ALPHANUM>",
"position": 11
},
{
"token": "and",
"start_offset": 86,
"end_offset": 89,
"type": "<ALPHANUM>",
"position": 12
},
{
"token": "the",
"start_offset": 90,
"end_offset": 93,
"type": "<ALPHANUM>",
"position": 13
},
{
"token": "crowd's",
"start_offset": 94,
"end_offset": 101,
"type": "<ALPHANUM>",
"position": 14
},
{
"token": "always",
"start_offset": 102,
"end_offset": 108,
"type": "<ALPHANUM>",
"position": 15
},
{
"token": "flowing",
"start_offset": 109,
"end_offset": 116,
"type": "<ALPHANUM>",
"position": 16
}
]
}
不道理給我。我正在使用停止分析器,結果中爲什麼會顯示「and」和「the」?我試圖將停止分析儀更改爲空白和標準,但是我得到與上述完全相同的結果。他們之間沒有區別。但是,如果我針對Elasticsearch 5.x的實例運行完全相同的查詢,則結果不再包含「and」和「the」,它看起來更像預期的那樣。
這是因爲我們使用1.7還是在我們的Elasticsearch設置中導致此問題?
編輯: 我使用感插件在Chrome做我的查詢,和插件不支持請求的身體得到這樣它改變了請求,POST。彈性分析API 1.7似乎不支持POST請求:(如果我改變這樣的查詢GET _analyze?analyzer = stop & text = THIS + is + a + test & pretty pretty works
我只是想出了這個問題我自己,我使用感插件在Chrome做我的查詢,並且該插件不支持使用請求主體的GET,因此它將請求更改爲POST。Elastic Analyze API 1.7似乎不支持POST請求:(如果我更改查詢是GET GET_analyze?analyzer = stop&text = THIS +是+ a + test&pretty它的工作原理 –
您對Sense的評價是真實的,我在回覆中提供的內容在Sense中進行了測試。如果我刪除了'?analyzer = stop'部分並將其放在體內,它將不再工作,但文本將被分析,但不會使用'stop'分析器。 –
哦,是的,我現在明白了:)但仍然更加整潔在2+ –