Skip to content

PR #138 breaks nested type #480

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

Closed
inkstak opened this issue Oct 15, 2015 · 9 comments
Closed

PR #138 breaks nested type #480

inkstak opened this issue Oct 15, 2015 · 9 comments

Comments

@inkstak
Copy link
Contributor

inkstak commented Oct 15, 2015

Hi,

The #138 breaks my app specs.
Why adding nested to TYPES_WITH_EMBEDDED_PROPERTIES ?

I use nested properties like this :

indexes :users, type: :nested do
  indexes :name_badge: 
end

to expect the following mapping :

"user": {
  "type": "nested",
  "properties": {
    "name": {
      "type": "string"
    }
  }
}

So now, properties becomes fields

According to https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-nested-type.html and https://www.elastic.co/guide/en/elasticsearch/reference/current/_multi_fields.html :

the field type multi_field has been removed. Instead, any of the core field types (excluding object and nested) now accept a fields parameter.

So, when recreating mapping, ES ignore the fields parameter, and the final mapping is now :

"user": {
  "type": "nested"
}
@eric-pigeon
Copy link

change nested to be a string instead of a symbol

indexes :users, type: "nested" do
  indexes :name_badge: 
end

@inkstak
Copy link
Contributor Author

inkstak commented Oct 28, 2015

Thanks @xxxpigeonxxx

@karmi
Copy link
Contributor

karmi commented Nov 3, 2015

@xxxpigeonxxx, thanks for the hint!

@inkstak Sorry for the delay. We should do .to_s on the type then.

@inkstak
Copy link
Contributor Author

inkstak commented Nov 3, 2015

But why adding nested to TYPES_WITH_EMBEDDED_PROPERTIES ?
Doesn't it go against the ES doc ?

@karmi
Copy link
Contributor

karmi commented Nov 4, 2015

@inkstak In what sense? Do you have a complete example which would demonstrate your point? Thanks!

@mmahalwy
Copy link

mmahalwy commented Nov 7, 2015

@karmi my example is I cannot get this:

mappings _all: { enabled: false } do
        indexes :text, {
          type: 'string',
          similarity: 'my_bm25',
          term_vector: 'with_positions_offsets_payloads',
          fields: {
            stemmed: {
              type: 'string',
              similarity: 'my_bm25',
              term_vector: 'with_positions_offsets_payloads',
              analyzer: 'standard'
            },
            # phonetic: {
            #   type: 'string',
            #   analyzer: 'dbl_metaphone'
            # }
          }
        }
      end

With this:

mappings _all: { enabled: false } do
        indexes :text, type: 'multi_field', similarity: 'my_bm25', term_vector: 'with_positions_offsets_payloads' do
          indexes :stemmed, type: 'string', similarity: 'my_bm25', term_vector: 'with_positions_offsets_payloads', analyzer: 'standard'
          indexes :phonetic, type: 'string', analyzer: 'dbl_metaphone'
        end
      end

Instead, in ES it becomes:

"text": {
"index": "no",
"type": "string",
"fields": {
"stemmed": {
"analyzer": "standard",
"similarity": "my_bm25",
"term_vector": "with_positions_offsets_payloads",
"type": "string"
},
"phonetic": {
"analyzer": "dbl_metaphone",
"type": "string"
}
}

@karmi
Copy link
Contributor

karmi commented Nov 8, 2015

@mmahalwy, sorry, don't get what you expect as the output?

karmi added a commit that referenced this issue Nov 8, 2015
…inst a string version of the passed field type

Related: #480
@mmahalwy
Copy link

mmahalwy commented Nov 9, 2015

@karmi sorry, should explain further. According to the ES docs, multi_field is deprecated. Therefore, in the code of doing

mappings _all: { enabled: false } do
        indexes :text, type: 'multi_field', similarity: 'my_bm25', term_vector: 'with_positions_offsets_payloads' do
          indexes :stemmed, type: 'string', similarity: 'my_bm25', term_vector: 'with_positions_offsets_payloads', analyzer: 'standard'
...

You'd expect to index:

text: {
          type: 'string',
          similarity: 'my_bm25',
          term_vector: 'with_positions_offsets_payloads',
          fields: {
            stemmed: {
              type: 'string',
              similarity: 'my_bm25',
              term_vector: 'with_positions_offsets_payloads',
              analyzer: 'standard'
            },
...

But what I get:

{
  "text": {
    "index": "no",
    "type": "string",
    "fields": {
      "stemmed": {
        "analyzer": "standard",
        "similarity": "my_bm25",
        "term_vector": "with_positions_offsets_payloads",
        "type": "string"
      },
      "phonetic": {
        "analyzer": "dbl_metaphone",
        "type": "string"
      }
    }
  }
}

when it should be:

{
  "text": {
    "analyzer": "standard",
    "similarity": "my_bm25",
    "term_vector": "with_positions_offsets_payloads",
    "type": "string",
    "fields": {
      "stemmed": {
        "analyzer": "standard",
        "similarity": "my_bm25",
        "term_vector": "with_positions_offsets_payloads",
        "type": "string"
      },
      "phonetic": {
        "analyzer": "dbl_metaphone",
        "type": "string"
      }
    }
  }
}

It made sense that multi_field previously did not have the text property to have any options such as analyzer, etc. because you'd have to explicitly set a field with the same name and those options, but with multi_field gone, one would expect it'd just set them on that and have different fields if developer wishes to include

@inkstak
Copy link
Contributor Author

inkstak commented Nov 9, 2015

@karmi your commit should fix the issue.
I didn't read well the #138 changes and didn't think that the problem was about the symbol/string equality. Thanks.

@mmahalwy you issue is different. You should open a new one so I can close this one.

@inkstak inkstak closed this as completed Nov 9, 2015
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

4 participants