Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

receive _type not indexed error, but documentation says _type is always indexed #31476

Closed
tonyyanga opened this issue Jun 20, 2018 · 2 comments
Closed
Labels
>docs General docs changes :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch

Comments

@tonyyanga
Copy link

Elasticsearch version (bin/elasticsearch --version):

Version: 6.3.0, Build: default/zip/424e937/2018-06-11T23:38:03.357887Z, JVM: 1.8.0_171

Plugins installed: None

JVM version (java -version):

openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-1~bpo8+1-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)

OS version (uname -a if on a Unix-like system):

Linux tony-laptop 3.16.0-4-amd64 #1 SMP Debian 3.16.51-3 (2017-12-13) x86_64 GNU/Linux

Description of the problem including expected versus actual behavior:

I run a query on _type field and received HTTP 400 for "cannot search on field [_type] since it is not indexed".

According to the documentation, "The _type field is indexed in order to make searching by type name fast." I expect to receive a correct result not an error.

Steps to reproduce:

Create mappings:

PUT /test_schema_1

{
  "settings":{
    "index":{
      "number_of_shards":1,
      "number_of_replicas":0
    }
  }
}
PUT /test_schema_1/_mapping/test_table_1

{"test_table_1":{"properties":{"text_field":{"type":"text"}}}}

Query:

POST /test_schema_1/test_table_1/_search?size=4000&preference=_shards%3A0&scroll=300000ms

{
  "from" : 0,
  "size" : 4000,
  "query" : {
    "range" : {
      "_type" : {
        "from" : " ",
        "to" : null,
        "include_lower" : false,
        "include_upper" : true,
        "boost" : 1.0
      }
    }
  }
}

Response:

{
    "error": {
        "root_cause": [
            {
                "type": "query_shard_exception",
                "reason": "failed to create query: {\n  \"range\" : {\n    \"_type\" : {\n      \"from\" : \" \",\n      \"to\" : null,\n      \"include_lower\" : false,\n      \"include_upper\" : true,\n      \"boost\" : 1.0\n    }\n  }\n}",
                "index_uuid": "B6LluE64RhqZhIoVufFXSQ",
                "index": "test_schema_1"
            }
        ],
        "type": "search_phase_execution_exception",
        "reason": "all shards failed",
        "phase": "query",
        "grouped": true,
        "failed_shards": [
            {
                "shard": 0,
                "index": "test_schema_1",
                "node": "7RkRZhIBQPKc43Lyr6ZY4A",
                "reason": {
                    "type": "query_shard_exception",
                    "reason": "failed to create query: {\n  \"range\" : {\n    \"_type\" : {\n      \"from\" : \" \",\n      \"to\" : null,\n      \"include_lower\" : false,\n      \"include_upper\" : true,\n      \"boost\" : 1.0\n    }\n  }\n}",
                    "index_uuid": "B6LluE64RhqZhIoVufFXSQ",
                    "index": "test_schema_1",
                    "caused_by": {
                        "type": "illegal_argument_exception",
                        "reason": "Cannot search on field [_type] since it is not indexed."
                    }
                }
            }
        ]
    },
    "status": 400
}

I am aware that _type is being deprecated. Should the documentation be updated to reflect that _type is no longer indexed? Or is there a bug?

@javanna javanna added the :Search Foundations/Mapping Index mappings, including merging and defining field types label Jun 21, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@javanna javanna added the >docs General docs changes label Jun 21, 2018
@cbuescher
Copy link
Member

I think the documentation might be off. Consider this PR that mentions that for single-type indices (which new ones on 6.x are by default) "_type" is no longer indexed).

Note that e.g. match ,term or simple_query_string queries work as long as you don't use e.g. wildcards:

POST /test_schema_1/test_table_1/_search
{
  "query" : {
    "match": {
      "_type": "test_table_1"
    }
  }
}
POST /test_schema_1/test_table_1/_search
{
  "query" : {
    "term": {
      "_type": {
        "value": "test_table_1"
      }
    }
  }
}
POST /test_schema_1/test_table_1/_search
{
  "query" : {
    "simple_query_string": {
      "query": "test_table_1",
      "fields": ["_type"]
    }
  }
}

cbuescher pushed a commit to cbuescher/elasticsearch that referenced this issue Jul 3, 2018
With the introduction of single types in 6.x, the `_type` field is no longer
indexed, which leads to certain queries that were working before throw errors
now. One such query is the `range` query, that, if performed on a single typer
index, currently throws an IAE since the field is not indexed.
This change adds special treatment for this case in the TypeFieldMapper,
comparing the range queries lower and upper bound to the one existing type and
either returns a MatchAllDocs or a MatchNoDocs query.

Relates to elastic#31632
Closes elastic#31476
cbuescher pushed a commit that referenced this issue Jul 18, 2018
With the introduction of single types in 6.x, the `_type` field is no longer
indexed, which leads to certain queries that were working before throw errors
now. One such query is the `range` query, that, if performed on a single typer
index, currently throws an IAE since the field is not indexed.
This change adds special treatment for this case in the TypeFieldMapper,
comparing the range queries lower and upper bound to the one existing type and
either returns a MatchAllDocs or a MatchNoDocs query.

Relates to #31632
Closes #31476
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this issue Jul 18, 2018
…31756)

With the introduction of single types in 6.x, the `_type` field is no longer
indexed, which leads to certain queries that were working before throw errors
now. One such query is the `range` query, that, if performed on a single typer
index, currently throws an IAE since the field is not indexed.
This change adds special treatment for this case in the TypeFieldMapper,
comparing the range queries lower and upper bound to the one existing type and
either returns a MatchAllDocs or a MatchNoDocs query.

Relates to elastic#31632
Closes elastic#31476
cbuescher pushed a commit that referenced this issue Jul 23, 2018
…32161)

With the introduction of single types in 6.x, the `_type` field is no longer
indexed, which leads to certain queries that were working before throw errors
now. One such query is the `range` query, that, if performed on a single typer
index, currently throws an IAE since the field is not indexed.
This change adds special treatment for this case in the TypeFieldMapper,
comparing the range queries lower and upper bound to the one existing type and
either returns a MatchAllDocs or a MatchNoDocs query.

Relates to #31632
Closes #31476
@javanna javanna added the Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>docs General docs changes :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch
Projects
None yet
Development

No branches or pull requests

4 participants