Elasticsearch NEST client [search] requests with source filtering are not working as expected


#1

Hello ,
I'm currently using elasticsearch NEST client v 6.0.0 with ES v6.1.2.
When i use NEST search request with source filtering to include the specified fields only in the returned documents, the source for each document will be empty!

Here is the debug info object i've got :

Valid NEST response built from a successful low level call on POST: /indexName/typeName/_search?
typed_keys=true
# Audit trail of this API call:
 - [1] HealthyResponse: Node: http://ESipAddress:9200/ Took: 00:00:00.0312084
# Request:
{"from":0,"size":50,"_source":{"includes":["ID","Name","Description","Category"]}}
# Response:
{"took":13,"timed_out":false,"_shards":{"total":2,"successful":2,"skipped":0,"failed":0},"hits":
{"total":154919,"max_score":1.0,"hits":
[{"_index":"indexName","_type":"typeName","_id":"45484","_score":1.0,"_source":{}} }}

And I'v noticed something, the following search request will return zero hits (its a valid request) when it was done via elastic NEST client but when i try to execute it from elastic Head on GET not POST the results are returned as expected . Here is the debug info of the request made:

Valid NEST response built from a successful low level call on POST: /content/_search?typed_keys=true
# Audit trail of this API call:
- [1] HealthyResponse: Node: http://localhost:9200/ Took: 00:00:00.0937397
# Request:
{"from":0,"size":50,"_source":true,"query":{"bool":{"must":[{"terms":{"ClassID":
["5","419","422","442","80","85","434","436","439","87","76"]}}]}}}
# Response:
{"took":16,"timed_out":false,"_shards":{"total":6,"successful":6,"skipped":0,"failed":0},"hits":
{"total":0,"max_score":null,"hits":[]}} 

Any thing may help ?


(Russ Cam) #2

What does the mapping look like for indexName?


#3

{
"state": "open",
"settings": {
"index": {
"refresh_interval": "5s",
"number_of_shards": "2",
"provided_name": "indexName",
"creation_date": "1517711010125",
"analysis": {
"analyzer": {
"case_insensitive_sort": {
"filter": [
"lowercase"
],
"type": "custom",
"tokenizer": "keyword"
}
}
},
"number_of_replicas": "1",
"uuid": "yMa2tL5qQZmCqaYeEfAePg",
"version": {
"created": "6010299"
}
}
},
"mappings": {
"typeName": {
"dynamic": "strict",
"_all": {
"enabled": false
},
"properties": {
"container": {
"type": "keyword"
},
"iD": {
"type": "keyword"
},
"name": {
"analyzer": "case_insensitive_sort",
"type": "text"
},
"description": {
"analyzer": "case_insensitive_sort",
"type": "text"
},
"category": {
"type": "keyword"
}
"location": {
"type": "keyword"
},
"sourceLocation": {
"index": false,
"type": "text"
},
"sourceName": {
"analyzer": "case_insensitive_sort",
"type": "text"
}
}
}
},
"aliases": [
"content"
],
"primary_terms": {
"0": 1,
"1": 1
},
"in_sync_allocations": {
"0": [
"VUdRpr2DQqSQwsXdkLCDXA"
,
"UMvsjttLQfyi7-UGOGZNAg"
],
"1": [
"pYsDWyP4Tj-42ivUi7xdfQ"
,
"Vh08AEZTT7uPSjjUqlskKQ"
]
}
}


(Russ Cam) #4

The names of the fields in the source includes need to match the names in the mapping.

If you look at the request in question, the field names are Pascal cased e.g. Name, but you can see in the mapping that field names are Camel cased e.g. name


#5

Yeah :flushed: I've modified that mistake and its working fine now Thank you .


(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.