当我如下搜索时,我成功获得了结果。这对句子(或完整单词)也有效。但是,部分单词找不到任何东西。
例如,让我们看看这句话:
embedded image can place here.
当我搜索embedded
时,它会找到此内容。但是embed
找不到任何东西。
让我告诉你:
GET _search
{
"query": {
"bool": {
"must": [
{
"match": {
"content": "Embedded"
}
}
],
"filter": [
{
"term": {
"user_id": 10
}
}
]
}
}
}
结果:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 6,
"successful" : 6,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.2876821,
"hits" : [
{
"_index" : "inbox",
"_type" : "mailbox",
"_id" : "8c76f6a5-115a-4102-94e6-a3abef914d13",
"_score" : 0.2876821,
"_source" : {
"user_id" : 10,
"content" : "Embedded image"
}
}
]
}
}
但是,只允许搜索单词embed
:
GET _search
{
"query": {
"bool": {
"must": [
{
"match": {
"content": "Embed"
}
}
],
"filter": [
{
"term": {
"user_id": 10
}
}
]
}
}
}
结果:为空...
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 6,
"successful" : 6,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
这样搜索时是否可以找到相关内容?请注意,当我搜索embed image
GET _search
{
"query": {
"bool": {
"must": [
{
"match": {
"content": "embed image"
}
}
],
"filter": [
{
"term": {
"user_id": 10
}
}
]
}
}
}
答案 0 :(得分:0)
我通过使用query_string
GET _search
{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "embed image",
"fields": [
"content"
]
}
}
],
"filter": [
{
"term": {
"user_id": 10
}
}
]
}
}
}