弹性搜索将一个原始场放在一个字段中 [英] elasticsearch put a raw field inside a field
问题描述
只需
此查询
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 tokensnew
andyork
(i.e. analyzed) - whereas the
city.raw
field will contain the single tokenNew 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屋!