Reputation: 10570
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
Upvotes: 2
Views: 1561
Reputation: 217314
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
city
field will contain the two tokens new
and york
(i.e. analyzed)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.
Upvotes: 3