Skip to content

Conversation

@colings86
Copy link
Contributor

This is in favour of just searching the _index field

Closes #12017

This is in favour of just searching the _index field

Closes #12017
@jpountz
Copy link
Contributor

jpountz commented Apr 13, 2016

This looks good to me. Let's maybe add a concrete example to the docs that shows how an IndicesQuery can be replaced with a BooleanQuery using the _index field?

@clintongormley
Copy link
Contributor

Hmmm... not quite replaceable. Queries in the indices query are only parsed on the listed indices - the same is not true for bool, eg, this example creates a parent mapping on one index, but not the other:

DELETE one,two

PUT one 
{
  "mappings": {
    "parent": {},
    "child": {
      "_parent": {
        "type": "parent"
      }
    }
  }
}

PUT two

The indices query allows you to query two indices with different mappings:

GET _search
{
  "query": {
    "indices": {
      "indices": [
        "one"
      ],
      "query": {
        "has_child": {
          "type": "child",
          "query": {"match_all": {}}
        }
      },
      "no_match_query": {"match_all": {}}
    }
  }
}

While this query will throw an exception about missing the parent type:

GET _search
{
  "query": {
    "bool": {
      "should": [
        {
          "bool": {
            "must": [
              {
                "term": {
                  "_index": "one"
                }
              },
              {
                "has_child": {
                  "type": "child",
                  "query": {
                    "match_all": {}
                  }
                }
              }
            ]
          }
        },
        {
          "bool": {
            "must_not": [
              {
                "term": {
                  "_index": "one"
                }
              }
            ]
          }
        }
      ]
    }
  }
}

That's why this change depends on #12016

@colings86
Copy link
Contributor Author

@clintongormley now we have #17751 and #17748 to deal with the above, are you ok for me to merge this?

@clintongormley
Copy link
Contributor

+1

@colings86 colings86 merged commit 90d0443 into elastic:master Apr 14, 2016
@colings86 colings86 deleted the deprecate/indicesQuery branch April 14, 2016 16:09
@javanna javanna mentioned this pull request Nov 28, 2016
javanna added a commit to javanna/elasticsearch that referenced this pull request Nov 30, 2016
The indices query is deprecated since 5.0.0 (elastic#17710). It can now be removed in master (future 6.0 version).
javanna added a commit that referenced this pull request Nov 30, 2016
The indices query is deprecated since 5.0.0 (#17710). It can now be removed in master (future 6.0 version).
@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

>deprecation :Search/Search Search-related issues that do not fall into other categories v5.0.0-alpha2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants