hey guys, i have pb,
i have this field
"rank": {
"properties": {
"id": {
"type": "string"
}
}
it return array and i need filter it
try like this
{
"filter": { "term": { "rank": "jun" } },
"random_score": {},
"weight": 150
},
but it doesn't help
Hi,
How about this filter?
{
"filter": { "term": { "rank.id": "jun" } }
}
i tried but it doesn't work too
Sorry, I made mistake in syntax.
How about this?
GET /_search
{
"query": {
"bool": {
"filter": [
{ "term": { "rank.id": "jun" }}
]
}
}
}
If it not works again, please tell me your whole Mapping?
GET /YOUR_INDEX_NAME/_mappings
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html
{"prof": {
"location": {
"properties": {
"city": {
"type": "string"
},
"id": {
"type": "long"
}
}
},
"rank": {
"properties": {
"id": {
"type": "string"
}
}
}
}
}
guys maybe someone know how do search?
In my environment(ES2.3.), this works...
(Because of string field (not text), I expected that it is ES 2.x.)
// create index
PUT test_index
{
"mappings": {
"prof": {
"properties": {
"location": {
"properties": {
"city": {
"type": "string"
},
"id": {
"type": "long"
}
}
},
"rank": {
"properties": {
"id": {
"type": "string"
}
}
}
}
}
}
}
// index a document
PUT test_index/prof/1
{
"location": {
"city": "sample",
"id": 1
},
"rank": {
"id": "sample2"
}
}
// search
GET test_index/prof/_search
{
"query": {
"bool": {
"filter": [
{ "term": { "rank.id": "sample2" }}
]
}
}
}
thx!!!
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.