Skip to content

Conversation

GaelTadh
Copy link
Contributor

@GaelTadh GaelTadh commented Oct 2, 2014

This commit adds support for _index to the term query, terms query, term filter and terms filter.
All of the below queries work as expected :

GET /*/_search
{
  "query": {
    "term": {
    "_index": {
      "value": "reddit"
    }
  }}
}

GET /*/_search
{
  "query" :
  {
    "terms": {
      "_index": [
        "reddit2"
        ]
    }
  }
}

GET /*/_search
{
  "query":
   {
     "filtered": {
       "query": {
     "match_all": {}
       },
       "filter": {
          "terms":
          {
            "_index": [  "reddit"]
          }
       }
     }
   }
}

GET /*/_search
{"query":
   {
     "filtered": {
       "query": {
     "match_all": {}
       },
       "filter": {
     "term": { "_index": { "value": "reddit" }}
       }
     }
   } }

Since these are evaluated for each index (to resolve mappings) this change simply tests to see if the index is the correct one and returns a MATCH_ALL or MATCH_NO.

Closes #3316

This commit adds support for _index to the term query, terms query, term filter and terms filter.
All of the below queries work as expected :
```
GET /*/_search
{
  "query": {
    "term": {
    "_index": {
      "value": "reddit"
    }
  }}
}

GET /*/_search
{
  "query" :
  {
    "terms": {
      "_index": [
        "reddit2"
        ]
    }
  }
}

GET /*/_search
{
  "query":
   {
     "filtered": {
       "query": {
     "match_all": {}
       },
       "filter": {
          "terms":
          {
            "_index": [  "reddit"]
          }
       }
     }
   }
}

GET /*/_search
{"query":
   {
     "filtered": {
       "query": {
     "match_all": {}
       },
       "filter": {
     "term": { "_index": { "value": "reddit" }}
       }
     }
   } }
```
Since these are evaluated for each index (to resolve mappings) this change simply tests to see if the index is the correct one and returns a MATCH_ALL or MATCH_NO.

Closes elastic#3316
This commit adds support for _index to the term query, terms query, term filter and terms filter.
All of the below queries work as expected :
```
GET /*/_search
{
  "query": {
    "term": {
    "_index": {
      "value": "reddit"
    }
  }}
}

GET /*/_search
{
  "query" :
  {
    "terms": {
      "_index": [
        "reddit2"
        ]
    }
  }
}

GET /*/_search
{
  "query":
   {
     "filtered": {
       "query": {
     "match_all": {}
       },
       "filter": {
          "terms":
          {
            "_index": [  "reddit"]
          }
       }
     }
   }
}

GET /*/_search
{"query":
   {
     "filtered": {
       "query": {
     "match_all": {}
       },
       "filter": {
     "term": { "_index": { "value": "reddit" }}
       }
     }
   } }
```
Since these are evaluated for each index (to resolve mappings) this change simply tests to see if the index is the correct one and returns a MATCH_ALL or MATCH_NO.

Closes elastic#3316
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to break multi-version clusters since we only print the difference from the default mapping in toXContent. I think this should remain true by default and the termQuery/termsFilter methods below should check that the field is indexed AND enabled?

@jpountz
Copy link
Contributor

jpountz commented Oct 8, 2014

@GaelTadh I left some (minor) comments

@markharwood
Copy link
Contributor

This may now be superseded by #12027 which works with the latest master and includes support for Match query etc too.

@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Query DSL labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>enhancement help wanted adoptme :Search/Search Search-related issues that do not fall into other categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Special case the _index field in queries

6 participants