弹性搜索将一个原始场放在一个字段中 [英] elasticsearch put a raw field inside a field

查看:60
本文介绍了弹性搜索将一个原始场放在一个字段中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需



此查询

  GET blabla / _search $ 
$ b $ _ $$ $ b

给出零结果



但这一个:

  GET blabla / _search 
{
_source:city

}

提供数百万个文件。



现场城市的映射是这样的:


$ b $ $$$$$$$$$$$$$$$ {
raw:{
type:string,
index:not_analyzed
}
}
},

,因为您看到 .raw 在那里。

解决方案

city.raw 字段是不存储在 _source 中,它只是编入索引,以便您可以搜索它并执行聚合。



当您索引文档时,如

  {city:New York} 




  • city 字段将包含两个令牌 york (即分析)

  • city.raw 字段将包含单个令牌 New York (即未分析)。



在第一个例子中,您正在尝试检索 city.raw 字段,但没有这样的字段存在,因为它是在分析过程中创建的合成字段。


Simply

this query

GET blabla/_search
{
  "_source": "city.raw"

}

gives zero results

but this one:

GET blabla/_search
    {
      "_source": "city"

    }

gives millions of documents.

the mapping for the field city is like this:

 "city": {
            "type": "string",
            "analyzer": "standard",
            "fields": {
              "raw": {
                "type": "string",
                "index": "not_analyzed"
              }
            }
          },

as you see the .raw is there. what am i dong wrong please

解决方案

The city.raw field is not stored in the _source it is just indexed so that you can search on it and perform aggregations on it.

What happens when you index a document such as

{ "city": "New York" }

is that

  • the city field will contain the two tokens new and york (i.e. analyzed)
  • whereas the city.raw field will contain the single token New York (i.e. not analyzed).

In your first example, you're trying to retrieve the city.raw field from the source, but no such field exists since it's a synthetic field created during the analysis process.

这篇关于弹性搜索将一个原始场放在一个字段中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆