opensearch-project / OpenSearch

🔎 Open source distributed and RESTful search engine.
https://opensearch.org/docs/latest/opensearch/index/
Apache License 2.0
9.43k stars 1.73k forks source link

[BUG] search_as_you_type not supporting multi-fields / subfields #5035

Open iceman91176 opened 1 year ago

iceman91176 commented 1 year ago

Describe the bug A search_as_you_type field accepts sub-fields in its mapping definition, but they are silently ignored. This issues has bee reported in elasticsearch here (https://github.com/elastic/elasticsearch/issues/56326) and has been fixed here (https://github.com/elastic/elasticsearch/pull/82430)

To Reproduce Create field title of type search_as_you_type with sub-field sortable

PUT my_test
{
  "mappings": {
    "properties": {
      "title": {
        "type": "search_as_you_type",
        "fields": {
          "sortable": {
            "type": "keyword",
            "ignore_above": 256,
            "normalizer": "lowercase_normalizer"
          }
        }
      }
    }
  },
  "settings": {
    "analysis": {
      "normalizer": {
        "lowercase_normalizer": {
          "filter": [
            "lowercase"
          ],
          "type": "custom"
        }
      }
    }
  }
}

No error, but sortable field is not present in the mapping

{
    "my_test": {
        "aliases": {},
        "mappings": {
            "properties": {
                "title": {
                    "type": "search_as_you_type",
                    "doc_values": false,
                    "max_shingle_size": 3
                }
            }
        },
        "settings": {
            "index": {
                "number_of_shards": "1",
                "provided_name": "my_test",
                "creation_date": "1667374518829",
                "analysis": {
                    "normalizer": {
                        "lowercase_normalizer": {
                            "filter": [
                                "lowercase"
                            ],
                            "type": "custom"
                        }
                    }
                },
                "number_of_replicas": "1",
                "uuid": "A8M-Yhf3ReOi3ydAs0bnwA",
                "version": {
                    "created": "136247827"
                }
            }
        }
    }
}

Expected behavior The mapping should contain all fields

Plugins All that are part of the default docker image

Host/Environment (please complete the following information):

macohen commented 1 year ago

confirmed as reproduced in v2.8 of OpenSearch. we'll take a deeper look in the next few weeks.

iceman91176 commented 2 months ago

Anything new ?

dblock commented 2 months ago

@iceman91176 doesn't look like anyone is working on this. Care to help? Maybe write a YAML REST test to start? https://github.com/opensearch-project/OpenSearch/blob/main/TESTING.md#testing-the-rest-layer