Hello there,
I am using elasticsearch 8.11 and have an index shown below:
PUT /topics/
{
"settings": {
"index.mapping.total_fields.limit": 2000,
"number_of_shards": 1,
"analysis": {
"filter": {
"greek_lowercase": {
"type": "lowercase",
"language": "greek"
}
},
"analyzer": {
"greek_custom": {
"type": "custom",
"tokenizer": "classic",
"filter": [
"greek_lowercase",
"asciifolding"
]
}
}
}
},
"mappings": {
"properties": {
"id": { "type": "integer" },
"topicId": { "type": "text" },
"status" : {"type": "text"},
"createdBy" : {"type": "text"},
"classificationCode" : {"type": "text"},
"topicNo" : {"type": "text"},
"creation" : {"type": "date"},
"creationDate" : {"type": "date"},
"submissionDate" : {"type": "date"},
"boardCode" : {"type": "text"},
"sensitiveData" : {"type": "integer"},
"isDeleted" : {"type": "integer"},
"forInformation" : {"type": "integer"},
"state" : {"type": "integer"},
"boardTopicName" : {"type": "text"},
"description" : {
"analyzer": "greek_custom",
"type": "text"
},
"name" : {
"analyzer": "greek_custom",
"type": "text"
},
"generalCategory" : {"type": "integer"},
"category" : {"type": "integer"},
"subCategory" : {"type": "integer"},
"creatorRole" : {"type": "integer"},
"creator" : {"type": "text"},
"applicanTtitle" : {"type": "text"},
"meetingNo" : {"type": "text"},
"boardId" : {"type": "text"},
"originator" :{
"properties": {
"id" : {"type" : "text"},
"name" : {
"type" : "text",
"analyzer" : "greek_custom"
}
}
},
"userpermissionslist" : {
"type": "nested",
"properties": {
"userCode" : {"type" : "text"},
"accessype" : {"type" : "integer"}
}
},
"grouppermissionslist" : {
"type": "nested",
"properties": {
"groupCode" : {"type" : "text"},
"accessype" : {"type" : "integer"}
}
},
"rolepermissionslist" : {
"type": "nested",
"properties": {
"userCode" : {"type" : "text"},
"startDate" : {"type" : "date"},
"endDate" : {"type" : "date"},
"IsDeleted" : {"type" : "integer"}
}
}
}
}
}
I would like to make a search from C# .net using a script for getting the submissionDate and searching in between startDate and endDate of the nested object within rolepermissionslist.
As far i have tried some script in kibana and it works. But the params._source is always null when i make the call from C# .net.
Kibana Code:
GET /topics/_search
{
"script_fields": {
"scripted": {
"script": {
"lang": "painless",
"source": """
if (params._source['submissionDate'] != null) {
return params._source;
}"""
}
}
}
}
C# Code:
mustList.Add(new Elastic.Clients.Elasticsearch.QueryDsl.ScriptQuery
{
QueryName = "named_query",
Script = new Script(new Elastic.Clients.Elasticsearch.InlineScript()
{
Language = "painless",
Source = "if(params._source['submissionDate'] != null) { return params._source; }"
})
});
C# always returns 0 hits and documents.