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

Get field mapping API returns empty response on wildcard-included search_as_you_type field #118636

Open
tmoschou opened this issue Dec 13, 2024 · 4 comments
Labels
>bug priority:normal A label for assessing bug priority to be used by ES engineers :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch

Comments

@tmoschou
Copy link

tmoschou commented Dec 13, 2024

Elasticsearch Version

8.16.1

Installed Plugins

analysis-icu, mapper-size

Java Version

OpenJDK Runtime Environment (build 17.0.13+12-LTS)

OS Version

Linux elasticsearch-master-0 5.10.207 #1 SMP PREEMPT Tue Sep 3 18:23:52 UTC 2024 aarch64 GNU/Linux

Problem Description

Get field mapping query with a wildcard field matching any field of type search_as_you_type causes server to respond with empty response {}.

Steps to Reproduce

  1. Create index

    curl -X PUT localhost:9200/my-index -H 'Content-Type: application/json' -d '
    {
        "mappings": {
            "properties": {
                "field1a": { "type": "search_as_you_type" },
                "field1b": { "type": "text" },
                "field2a": { "type": "text" },
                "field2b": { "type": "text" }
            }
        }
    }'
    
  2. Query field mapping

    curl -X GET 'localhost:9200/my-index/_mapping/field/field1*'
    

    Expected behaviour

    Step 2 returns:

    {
      "my-index": {
        "mappings": {
          "field1a": {
            "full_name": "field1a",
            "mapping": {
              "field1a": {
                "type": "search_as_you_type",
                "doc_values" : false,
                "max_shingle_size" : 3
              }
            }
          },
          "field1b": {
            "full_name": "field1b",
            "mapping": {
              "field1b": {
                "type": "text"
              }
            }
          }
        }
      }
    }
    

    Actual behaviour
    Step 2 returns:

    {}
    

    Not only is field1a not returned, but neither is any other field matched (E.g. field1b, or all other fields if using /_mapping/field/* ).

  3. Querying non-existing fields return differently

    curl -X GET 'localhost:9200/my-index/_mapping/field/field3*'
    {"my-index":{"mappings":{}}}
    
  4. Querying the search_as_you_type exactly without wildcard does work

    curl -X GET 'localhost:9200/my-index/_mapping/field/field1a'
    {
      "my-index": {
        "mappings": {
          "field1a": {
            "full_name": "field1a",
            "mapping": {
              "field1a": {
                "type": "search_as_you_type",
                "doc_values": false,
                "max_shingle_size": 3
              }
            }
          }
        }
      }
    }
    

Logs (if relevant)

No logs lines are written

@tmoschou tmoschou added >bug needs:triage Requires assignment of a team area label labels Dec 13, 2024
@tmoschou
Copy link
Author

tmoschou commented Dec 13, 2024

Workaround might be to use the Field Capabilities API, although it will not have some of the details of the Field Mapping API.

curl 'http://localhost:9200/my-index/_field_caps?fields=field1*'

@javanna
Copy link
Member

javanna commented Dec 13, 2024

Could you use the get mappings API instead?

@javanna javanna added :Search Foundations/Mapping Index mappings, including merging and defining field types priority:normal A label for assessing bug priority to be used by ES engineers and removed needs:triage Requires assignment of a team area label labels Dec 13, 2024
@elasticsearchmachine elasticsearchmachine added the Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch label Dec 13, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-foundations (Team:Search Foundations)

@tmoschou
Copy link
Author

Could you use the get mappings API instead?

Yep mapping API would work too 🙃 - with a bit more client side work for our use case. For context, our use case being we want to run Update Mapping Request in dry-run mode (or validate ahead) to know if the request would a) succeed, and b) cause a change in the mapping - dry-run doesn't seem possible, so need to query the fields in the update mapping request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug priority:normal A label for assessing bug priority to be used by ES engineers :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

3 participants