1

I'm new to elasticsearch. And can't to find out how to make correct request to an index and an type within JSON request? (So i'd like to not use index and type in URL like localhost:9200/myindex/mytype/_search , but to make JSON request to localhost:9200/_search )

I tried something like this. But i got results from 'aaa' index instead of 'bbb' index. How to get results only from bbb index or no results at all?

{
  "query": {
    "indices": {
      "indices": [
        "bbb"
      ],
      "query": {
        "bool": {
          "must": [
            {
              "range": {
                "apps.vol": {
                  "lte": 1
                }
              }
            },
            {
              "term": {
                "apps.status": 2
              }
            }
          ],
          "must_not": [],
          "should": []
        }
      }

    }
  }
  ,"size":2,"sort":[],"facets":{}
}
2
  • what are the documents you are supposed to get from bbb? Commented May 5, 2014 at 16:55
  • just a few fileds with string and numeric values. Each documents is less than 256 bytes in total. Commented May 5, 2014 at 23:21

1 Answer 1

2

According to http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-indices-query.html, the default no_match_query is "all". You need to add "no_match_query" : "none" at the same level as your "query":

Sign up to request clarification or add additional context in comments.

1 Comment

thanks. It works fine. But now I got some SearchContextMissingException[No search context found for id...] errors. Search is very fast (less than 1sec). Is it possible because I do "_scan + _scroll" instead of "_search + from + size"?

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.