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

[BUG] _type value in field of exists query returns all records #2989

Closed
dreamer-89 opened this issue Apr 19, 2022 · 4 comments
Closed

[BUG] _type value in field of exists query returns all records #2989

dreamer-89 opened this issue Apr 19, 2022 · 4 comments
Assignees
Labels
bug Something isn't working Indexing & Search v2.0.0 Version 2.0.0

Comments

@dreamer-89
Copy link
Member

Describe the bug
_type value for field in exists query fetches records but post type removal in #1940, _type should be considered as a random value and shouldn't return any record.

To Reproduce
Request

curl -X PUT localhost:9200/test-index

curl -X POST localhost:9200/test-index/_doc -d '{ 
    "field" : "value"
}'

curl -X POST localhost:9200/test-index/_doc -d '{ 
    "field" : "value2"
}'

curl -XPOST localhost:9200/test-index/_search?pretty -d '
{
    "query": {
        "exists": {
            "field": "_type"
         }
    }
}'

Response

{
    "took": 2,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 4,
            "relation": "eq"
        },
        "max_score": 1.0,
        "hits": [
            {
                "_index": "test-index",
                "_id": "kvyyQ4ABr3FIIAx07N_Z",
                "_score": 1.0,
                "_source": {
                    "field": "value"
                }
            },
            {
                "_index": "test-index",
                "_id": "lfy6Q4ABr3FIIAx0k9_1",
                "_score": 1.0,
                "_source": {
                    "field": "value2"
                }
            }
        ]
    }
}

Expected behavior
_type field handled as any other random field and should return empty response.

@dreamer-89 dreamer-89 added bug Something isn't working untriaged labels Apr 19, 2022
@dreamer-89 dreamer-89 changed the title [BUG] _type value in field of exists query [BUG] _type value in field of exists query returns all records Apr 19, 2022
@dreamer-89
Copy link
Member Author

A straightforward fix is to have check on _type in ExistsQueryBuilder here but that would mean a separate handling for _type fields and throwing exception.

This will not be a good solution as it introduces explicit check for _type keyword. Instead of this, engine should return empty response as it does for any other random field.

@dreamer-89 dreamer-89 self-assigned this Apr 20, 2022
@nknize
Copy link
Collaborator

nknize commented Apr 20, 2022

We need to remove TypeFieldMapper since _type should no longer be supported.

@elfisher
Copy link

Should this issue still be open? It looks like this was merged #3016

@dreamer-89
Copy link
Member Author

Closing this issue as bug is fixed.

There is some clean up work pending related with removing TypeFieldMapper class from code base. This cleanup PR can be raised once #3004 is merged; as it removes remaining TypeFieldMapper references from the codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Indexing & Search v2.0.0 Version 2.0.0
Projects
None yet
Development

No branches or pull requests

4 participants