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

Support include_defaults in the GET-mapping API #5368

Closed
clintongormley opened this issue Mar 8, 2014 · 14 comments
Closed

Support include_defaults in the GET-mapping API #5368

clintongormley opened this issue Mar 8, 2014 · 14 comments
Labels
:Search/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team won't fix

Comments

@clintongormley
Copy link

The get-field-mapping API only works for core field types, not for fields of type object or nested:

curl -XPUT "http://localhost:9200/test" -d'
{
  "mappings": {
    "test": {
      "properties": {
        "foo": {
          "type": "object",
          "properties": {
            "bar": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}'

Retrieving the mapping for core fields works:

curl -XGET "http://localhost:9200/test/_mapping/test/field/foo.bar"

Result:

{
   "test": {
      "mappings": {
         "test": {
            "foo.bar": {
               "full_name": "foo.bar",
               "mapping": {
                  "bar": {
                     "type": "string"
                  }
               }
            }
         }
      }
   }
}

But not for fields of type object or nested:

curl -XGET "http://localhost:9200/test/_mapping/test/field/foo"

Result:

{}
@bleskes
Copy link
Contributor

bleskes commented Mar 10, 2014

This tricky as the get field mappings api also supports wild cards ( #4367 ) which people use to get a list of all searchable fields. This is handy for suggestions of field names (i.e., a kibana panel facet configuration).

Also - if you specify curl -XGET "http://localhost:9200/index/type/_mapping/field/*" it's ambiguous what you'd get - object fields only ? object fields and leaf fields unpacked?

we could potentially add flags for this but I'm not sure it's worth it. Perhaps a documentation issue or find better url structure (using a clearer word than fields)?

@clintongormley
Copy link
Author

The particular use case I had was wanting to see if include_in_parent|root were being defaulted to false. There is no way of seeing this currently.

For wildcards, I'd say you include the object plus all of its properties.

This tricky as the get field mappings api also supports wild cards ( #4367 ) which people use to get a list of all searchable fields. This is handy for suggestions of field names (i.e., a kibana panel facet configuration).

Perhaps just a query string flag to distinguish between searchable fields and all fields, eg:

GET /index/_mapping/type/field/*?searchable

@Mpdreamz
Copy link
Member

I have to agree with @clintongormley it would be great if it did support object|nested this endpoint is great to zoom in whether a field was indeed properly mapped without the surrounding noise the regular _mapping endpoint gives you.

When I first read the documentation I did not equate field with leaf fields.

GET /index/_mapping/type/field/*?leafs

or since the default is already to only show leafs:

GET /index/_mapping/type/field/*?include_object

Since wildcards already flatten the result it would be great if the mapping for objects excludes its own properties.

@clintongormley
Copy link
Author

I think the main thing that is missing here is support for include_defaults on the main GET-mapping API. While getting a single object mapping to check that it is mapped correctly would be nice, it's a one-off debugging request, and is not as important as the current function of the GET-field-mapping: returning all searchable fields as a flat list.

So I'd be happy with just adding support for include_defaults to GET-mapping

@clintongormley clintongormley changed the title Get-field-mapping doesn't work for nested or object fields Support include_defaults in the GET-mapping API Oct 17, 2014
@clintongormley clintongormley added help wanted adoptme and removed discuss labels Oct 17, 2014
@Mpdreamz
Copy link
Member

If that toggles including object and nested fields as well +1

@clintongormley
Copy link
Author

@Mpdreamz the change i'm suggesting is to the main get-mapping API, not the get-field-mapping API. So my request doesn't allow you to retrieve a single object field, you still have to retrieve the old mapping. However, you can get back the mapping with the defaults included.

@bleskes
Copy link
Contributor

bleskes commented Oct 17, 2014

I'm +1 on adding an include default + filtering options (including indexed, which is i think is better than searchable because it's the name of the setting, nested or what ever) . Once we have that, we can depreciate the get field mappings API imho.

Caveat - The get field mapping api was added and implemented in the current form (i.e., requiring at least one assigned shard) because the defaults are currently baked in the the field mapper in memory objects. To so on the master and based on the serialized representation of the _mapping, we need to have a better grip on the defaults (or if we just choose to instantiate these objects with every request).

@csezheng
Copy link

csezheng commented Jul 2, 2015

+1 to add the include_defaults option to get mapping API, and also makes it work for the object type field.

@csezheng
Copy link

csezheng commented Jul 2, 2015

If this is not gonna be fixed soon, is there any alternative way to get the default values for the object/nested type fields? Thanks.

@clintongormley clintongormley added discuss :Search/Mapping Index mappings, including merging and defining field types and removed help wanted adoptme labels Oct 14, 2015
@jpountz
Copy link
Contributor

jpountz commented Nov 13, 2015

We just discussed it in Fixit Friday and are +1 on @bleskes 's plan. Making it an adoptme as well as a high-hanging fruit because of the described caveats...

roidelapluie added a commit to roidelapluie/es-find-doc-values that referenced this issue Mar 21, 2016
@clintongormley
Copy link
Author

Rediscussed in FixItFriday - would be good to:

  • remove the field mapping API
  • add support for include_defaults to the mapping API
  • users can use response filtering for a particular field
  • perhaps we can support flat_paths to return fields like foo.bar.baz instead of using JSON objects

@rjernst is the following still true after the mapping refactoring you did?

Caveat - The get field mapping api was added and implemented in the current form (i.e., requiring at least one assigned shard) because the defaults are currently baked in the the field mapper in memory objects. To so on the master and based on the serialized representation of the _mapping, we need to have a better grip on the defaults (or if we just choose to instantiate these objects with every request).

@jpountz
Copy link
Contributor

jpountz commented Mar 13, 2018

cc @elastic/es-search-aggs

@mayya-sharipova
Copy link
Contributor

The issue of still relevant. cc @elastic/es-search-aggs

@javanna
Copy link
Member

javanna commented Jun 16, 2022

It's been a long time since this issue was discussed last. The get field mappings API has effectively been replaced by the field caps API. We have not removed the API due to the breaking nature of such a change but we would expect users to rely on field_caps to inspect the fields and their capabilities. In case mappings need to be inspected instead, get mappings is the way to go. As for adding support for include_defaults to get mappings, I doubt that it would be useful today given that most users should rely on field_caps, hence I am going to close this issue. Feel free to comment or reopen if you think otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Search/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team won't fix
Projects
None yet
Development

No branches or pull requests

8 participants