Stored fields not coming back when the document is fetched


(Erdinc Yilmazel) #1

Hi all,

I have a mapping that declares all individual fields to be stored. The
_source is disabled. (I know that this isn't recommended over _source being
enabled).

I put my documents into the index without a problem after creating an index
with the following mapping and even if I specify the fields to be fetched
using _fields argument, I don't get the fields that I ask for back.

Mapping:

{
"mappings":{
"postalCode":{
"_type" : {"store" : "no"},
"_index" : { "enabled" : false },
"_source":{
"enabled":false
},
"properties":{
"countryCode":{"type":"string", "index":"analyzed",
"store":"yes", "_analyzer": {"path": "simple"}},
"postalCode":{"type":"string", "index":"analyzed",
"store":"yes", "_analyzer": {"path": "simple"}},
"geoCode":{"type":"geo_point", "store":"yes"},
"name":{"type":"string", "index":"analyzed", "store":"yes"},
"state1":{"type":"string", "index":"analyzed",
"store":"yes"},
"state2":{"type":"string", "index":"analyzed",
"store":"yes"},
"county1":{"type":"string", "index":"analyzed",
"store":"yes"},
"county2":{"type":"string", "index":"analyzed",
"store":"yes"},
"community1":{"type":"string", "index":"analyzed",
"store":"yes"},
"community2":{"type":"string", "index":"analyzed",
"store":"yes"},
"region":{"type":"string", "index":"analyzed", "store":"no"}
}
}
}
}

My get request:

http://localhost:9200/postalcodes/postalCode/100??fields=postalCode,geoCode,name

Response:

{"_index":"postalcodes","_type":"postalCode","_id":"100","_version":1,"exists":true}

I am expecting to see the postalCode, geoCode and name fields in the response, but they don't exist. I don't want to see _index and _type in the returned json document but I still see them. What am I doing wrong?

Finally, when I go to http://localhost:9200/postalcodes/postalCode/_mapping, I get a mapping back which isn't exactly the same as the mapping that I give to the create index command. I still get back all the fields and "store": "yes" properties, but the analyzer settings disappear.

I would appreciate any help.

Thanks,

Erdinc

--


(Clinton Gormley) #2

Hiya

http://localhost:9200/postalcodes/postalCode/100??fields=postalCode,geoCode,name

Could it be the double ??

Finally, when I go to
http://localhost:9200/postalcodes/postalCode/_mapping, I get a mapping
back which isn't exactly the same as the mapping that I give to the
create index command. I still get back all the fields and "store":
"yes" properties, but the analyzer settings disappear.

That's because you're using "_analyzer" instead of "analyzer"

clint

--


(system) #3