i have created a index and indexed data in array data type.Index and data details are as follows:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [
{
"_index" : "equitydata",
"_type" : "record",
"_id" : "fr1geGoBbfuDtN8fSkR2",
"_score" : 1.0,
"_source" : {
"test" : [
{
"sourceRowNumber" : 6,
"sourceColName" : "Trade Days",
"result" : "null"
},
{
"sourceRowNumber" : 6,
"sourceColName" : "Period End Valuation Type Code",
"result" : "true"
},
{
"sourceRowNumber" : 6,
"sourceColName" : "Period Timestamp",
"result" : "true"
}
]
}
}
]
}
}
Now i need to query to match only those records, which having **"result":"true"**.So i have written this query:
GET /equitydata/_search
{
"query": {
"bool": {
"must": {
"match": {
"text": "test.result"
}
},
"filter": {
"term": {
"test.result.keyword": "true"
}
}
}
}
}
Query-result:
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
Where i am doing wrong?
Is anything i need to change in mapping or else what i have to do, please suggest me.
Please format your code, logs or configuration files using </>
icon as explained in this guide and not the citation button. It will make your post more readable.
Or use markdown style like:
```
CODE
```
This is the icon to use if you are not using markdown format:
There's a live preview panel for exactly this reasons.
Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.
Please update your post.
Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.
A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.
hi @vinayak,
can you check this query
{
"query": {
"nested": {
"path": "test",
"query": {
"bool": {
"must": [
{
"term": {
"test.result": "true"
}
}
]
}
}
}
}
}
thanks for your reply.I have tried this:
GET equitydata/record/_search
{
"query": {
"nested": {
"path": "test",
"query": {
"bool": {
"must": [
{ "term": { "test.result": "true" }}
]
}
}
}
}
}
and result is:
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.47000363,
"hits" : [
{
"_index" : "equitydata",
"_type" : "record",
"_id" : "f71xeGoBbfuDtN8fH0S1",
"_score" : 0.47000363,
"_source" : {
"test" : [
{
"sourceRowNumber" : 6,
"sourceColName" : "Trade Days",
"result" : "null"
},
{
"sourceRowNumber" : 6,
"sourceColName" : "Period End Valuation Type Code",
"result" : "true"
},
{
"sourceRowNumber" : 6,
"sourceColName" : "Period Timestamp",
"result" : "true"
}
]
}
}
]
}
}
No success, sorry.
Sorry for that. Now done.Formatted it accordingly.
Hi @vinayak,
can you check your mapping ,you need to update your mapping the type of test array in mapping like this .
ref : https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html
PUT my_index
{
"mappings": {
"properties": {
"test": {
"type": "nested"
}
}
}
}
Hi johnrabi,
i have already done that. But if we want to see that result then we need to use inner_hits:{}.
then only we will able to see the filter result. or else it will show only_source hits record.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.