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

Cannot add multi-field index mapping for the LongField #3237

Open
yuri-rs opened this issue Dec 9, 2024 · 3 comments
Open

Cannot add multi-field index mapping for the LongField #3237

yuri-rs opened this issue Dec 9, 2024 · 3 comments

Comments

@yuri-rs
Copy link

yuri-rs commented Dec 9, 2024

I'd like to have the following index template mapping:

  "mappings": {
    "properties": {
      "long_field": {
        "type": "long",
        "fields": {
          "str": {
            "type": "keyword"
          }
        }
      },
...

Please note that I have multi-field for a Long field and it works fine.
I can create such mapping using 8.x Kibana

But I cannot create the same mapping programmatically using elastic4s, because there is no fields parameter in
LongField.scala

How can I create the mapping above using elastic4s now?
In the past (6.x) it was possible using BasicField.fields

@Philippus
Copy link
Owner

Fields are not mentioned here https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html. I'm also having trouble finding it in the Elasticsearch source code.

@yuri-rs
Copy link
Author

yuri-rs commented Dec 9, 2024

In java API it is defined as:
https://github.com/elastic/elasticsearch-specification/blob/d9bf86fe712f25f7ef5c0037eab484a22008c896/specification/_types/mapping/core.ts#L58

export class CorePropertyBase extends PropertyBase {
  copy_to?: Fields
  store?: boolean
}

export class DocValuesPropertyBase extends CorePropertyBase {
  doc_values?: boolean
}

export class BinaryProperty extends DocValuesPropertyBase {
  type: 'binary'
}

export class BooleanProperty extends DocValuesPropertyBase {
  boost?: double
  fielddata?: NumericFielddata
  index?: boolean
  null_value?: boolean
  type: 'boolean'
}

And PropertyBase

export class PropertyBase {
  /**
   * Metadata about the field.
   * @doc_id mapping-meta-field
   */
  meta?: Dictionary<string, string>
  properties?: Dictionary<PropertyName, Property>
  ignore_above?: integer
  dynamic?: DynamicMapping
  fields?: Dictionary<PropertyName, Property>
}

@yuri-rs
Copy link
Author

yuri-rs commented Dec 9, 2024

So, it seems that any field can have fields inside based on the spec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants