如何在弹性搜索中忽略空格?

时间:2018-04-10 12:14:29

标签: elasticsearch

我发送请求:

GET http://localhost:9200/test1/group/_search?q=White House

我得到了这个回应:

        {
            "_index": "test1",
            "_type": "group",
            "_id": "Bs3LqmIBHyTtDqASiuXU",
            "_score": 4.5936766,
            "_source": {
                "group": "bank 3",
                "type": "comment",
                "data": "White House",
                "author": "author 13"
            }
        },
        {
            "_index": "test1",
            "_type": "group",
            "_id": "Zs11r2IBHyTtDqAS8OXf",
            "_score": 3.2117434,
            "_source": {
                "group": "bank 2",
                "type": "task",
                "data": "White",
                "author": "author 1"
            }
        }

如何编写仅返回白宫的查询?

2 个答案:

答案 0 :(得分:0)

我认为你应该尝试' +'或%20作为空格字符。

https://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

或者,如果可以发送格式正确的HTTP请求。

答案 1 :(得分:0)

将白宫文本用引号括起来。这样,执行短语搜索。像这样:

_search?q =“白宫”

默认情况下,它是匹配搜索,用于查找任何单词。

相关问题