在elasticsearch中匹配一个字符串?
问题描述:
我使用ES 2.4.0在elasticsearch中匹配一个字符串?
我必须匹配字符串它会是这样"{hi} {ARE} {how} {You}"
我给出这样的查询
{
"query": {
"match": {
"simple": "{hi} {ARE} {how} {You}"
}
}
}
在输出它显示所有文件而不是匹配确切字符串(即简单)值的文档。
注意:这是在映射级别进行分析。
答
如果你想匹配在同一顺序的所有关键字,你应该使用match_phrase
{
"query": {
"match_phrase": {
"simple": "{hi} {ARE} {how} {You}"
}
}
}
如果你并不需要以相同的顺序的话,但只希望这一切话是出现在搜索结果中,然后使用match
与operator
。
{
"query": {
"match": {
"simple": {
"query": "{hi} {ARE} {how} {You}",
"operator": "and"
}
}
}
}
Thanks..it帮助 – Seeker