带有斜杠 return 零条目的 elasticsearch 中的通配符
Wildcard in elastichsearch with slash return zero entry
我正在使用 elastichsearch 5 来存储和搜索一些文档。
在我的文档中,我有一个名为 URL 的字段,如下所示:
{
//... other fields
"URL": "http://ip:8080/app/addItemToCart.html?workingItemId=X1"
}
我尝试使用带通配符的查询,因为我想获取所有在 URL 中包含单词 "addItemToCart" 的文档。
这是我的查询:
GET myindex/_search
{
"query" : {
"wildcard" : { "URL" : "*addItemToCart*" }
}
}
它 returns 零个文档,但我在 elasticsearch 中有包含该关键字的文档。
这是我的索引映射。
GET myindex/_mapping
{
//.... other fields
"URL": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
怎么了?
如前所述in the documentation,一个通配符查询
Matches documents that have fields matching a wildcard expression (not analyzed)
因此,您的查询应该是:
GET myindex/_search
{
"query" : {
"wildcard" : { "URL.keyword" : "*addItemToCart*" }
}
}
我正在使用 elastichsearch 5 来存储和搜索一些文档。 在我的文档中,我有一个名为 URL 的字段,如下所示:
{
//... other fields
"URL": "http://ip:8080/app/addItemToCart.html?workingItemId=X1"
}
我尝试使用带通配符的查询,因为我想获取所有在 URL 中包含单词 "addItemToCart" 的文档。 这是我的查询:
GET myindex/_search
{
"query" : {
"wildcard" : { "URL" : "*addItemToCart*" }
}
}
它 returns 零个文档,但我在 elasticsearch 中有包含该关键字的文档。
这是我的索引映射。
GET myindex/_mapping
{
//.... other fields
"URL": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
怎么了?
如前所述in the documentation,一个通配符查询
Matches documents that have fields matching a wildcard expression (not analyzed)
因此,您的查询应该是:
GET myindex/_search
{
"query" : {
"wildcard" : { "URL.keyword" : "*addItemToCart*" }
}
}