0

I want to query similary follow's SQL :

select * from talbe where id=cityid

Who know how to implement in es ?

thanks for your answer !

2

1 Answer 1

0

You can do this with a script filter like this:

POST /table/_search
{
  "query": {
    "bool": {
      "filter": {
        "script": {
          "script": "doc.id.value == doc.cityid.value"
        }
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

6 Comments

Only numeric fields may be accessed,Do you have any other way ?
my id and cityid is string
have you tried the script? == in groovy is like equals in Java
thanks @Val , i need time to study how to use groovy in es, if sucess, i can update this problem status ,thanks again !
You simply need to enable dynamic scripting in elasticsearch.yml, restart ES and that's it.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.