3
我使用的是官方Elasticsearch客戶的NodeJS庫,查詢以下索引結構:Elasticsearch - 基於文本的長度查詢
{
"_index": "articles",
"_type": "context",
"_id": "1",
"_version": 1,
"found": true,
"_source": {
"article": "this is a paragraph",
"topic": "topic A"
}
}
{
"_index": "articles",
"_type": "context",
"_id": "2",
"_version": 1,
"found": true,
"_source": {
"article": "this is a paragraph this is a paragraph this is a paragraph",
"topic": "topic B"
}
}
我想使用術語查詢我的指數「,這是一段」和提高的結果最相似的文本長度,即:文檔_id:1
我能做到這一點,而無需重新索引和添加字段到我的指數(as described here)?
如果你不能改變映射或做一個重新索引,那麼可能在查詢時Groovy腳本? –
感謝您的回覆,我是彈性搜索新手......您詳細闡述的顏色。 –
嗯...讓我發表一個示例查詢作爲例子... –