Radial search not working in opensearch 3.0

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
3.0.0

Describe the issue:

Radial search not working in opensearch 3.0.0 neural block and min_Score

GET my_index/_search
{
  "track_total_hits": true,
  "size": 10,
  "query": {
    "neural": {
      "my_vector_field": {
        "query_text": "my query text",
        "model_id": "myModelID",
        "min_score": 0.5
      }
    }
  },
  "explain": true
}

Configuration:

Relevant Logs or Screenshots:
getting and error

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "[knn] requires exactly one of k, distance or score to be set"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "my_index",
        "node": "ewfewolmlknmckc2dfew",
        "reason": {
          "type": "illegal_argument_exception",
          "reason": "[knn] requires exactly one of k, distance or score to be set"
        }
      }
    ],
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "[knn] requires exactly one of k, distance or score to be set",
      "caused_by": {
        "type": "illegal_argument_exception",
        "reason": "[knn] requires exactly one of k, distance or score to be set"
      }
    }
  },
  "status": 400
}

@pablo please help, any suggestions, Thanks

@vinod0x01 I’ve got this working.

GET my-nlp-index/_search
{
  "track_total_hits": true,
  "size": 10,
  "query": {
    "neural": {
      "passage_embedding": {
        "query_text": "Hi world",
        "model_id": "WN4wfZcBrZJhTKQi56zT",
        "min_score": 0.5
      }
    }
  },
  "explain": true
}
{
  "took": 36,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 2,
      "relation": "eq"
    },
    "max_score": 0.8032797,
    "hits": [
      {
        "_shard": "[my-nlp-index][0]",
        "_node": "jBP7oJ3uRmStBOiXr7_7Jg",
        "_index": "my-nlp-index",
        "_id": "1",
        "_score": 0.8032797,
        "_source": {
          "passage_text": "Hello world",
          "passage_embedding": [

However, when I add extra characters to the name of the field I get exactly as reported error.

GET my-nlp-index/_search
{
  "track_total_hits": true,
  "size": 10,
  "query": {
    "neural": {
      "passage_embedding_this_is_my_extra_string": {
        "query_text": "Hi world",
        "model_id": "WN4wfZcBrZJhTKQi56zT",
        "min_score": 0.5
      }
    }
  },
  "explain": true
}
{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "[knn] requires exactly one of k, distance or score to be set"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",

Also to complicate this more, it doesn’t happen all of the time. Sometimes I will get an error about a missing field using the same query.

{
  "error": {
    "root_cause": [
      {
        "type": "query_shard_exception",
        "reason": "failed to create query: Field 'passage_embedding_this_is_my_extra_string' is not knn_vector type.",

Which model did you use with your query?
Mine is huggingface/sentence-transformers/all-distilroberta-v1 version 1.0.2.

Thank you @pablo for quick response

  • I am using a custom model to generate embeddings of size 748 and the model is trained using over base huggingface bert model only
  • the thing is it used to work in opensearch 2.19 but started giving this error on 3.0

Hi @Navneet, any suggestions here can you please help, Thank you

Could you help with your Index Mapping . GET my-nlp-index/_mapping

Hi @viktari, thank you for response.
This is the index template i am using

{
  "index_templates": [
    {
      "name": "my-index",
      "index_template": {
        "index_patterns": [
          "my-index*"
        ],
        "template": {
          "settings": {
            "index": {
              "replication": {
                "type": "SEGMENT"
              },
              "mapping": {
                "total_fields": {
                  "limit": "17000"
                }
              },
              "search": {
                "slowlog": {
                  "threshold": {
                    "fetch": {
                      "warn": "1500ms",
                      "debug": "1s",
                      "info": "1200ms"
                    },
                    "query": {
                      "warn": "1200ms",
                      "debug": "800ms",
                      "info": "1s"
                    }
                  }
                }
              },
              "refresh_interval": "10m",
              "number_of_shards": "4",
              "auto_expand_replicas": "0-all",
              "merge": {
                "policy": {
                  "max_merge_at_once": "28",
                  "segments_per_tier": "3",
                  "floor_segment": "250mb",
                  "deletes_pct_allowed": "20"
                }
              },
              "knn": "true",
              "analysis": {
                "filter": {
                  "text_general_2_autophrase_synonym_graph_filter_index": {
                    "expand": "true",
                    "type": "synonym_graph",
                    "synonyms_path": "custom/products/autophrase-synonyms.txt",
                    "lenient": "true"
                  },
                  "text_general_7_stop_filter_query": {
                    "ignore_case": "true",
                    "type": "stop",
                    "stopwords_path": "custom/products/stopwords.txt"
                  },
                  "text_general_5_synonym_graph_filter_query": {
                    "updateable": "true",
                    "expand": "true",
                    "type": "synonym_graph",
                    "synonyms_path": "custom/products/synonyms.txt",
                    "lenient": "true"
                  },
                  "text_general_2_autophrase_synonym_graph_filter_query": {
                    "updateable": "true",
                    "expand": "true",
                    "type": "synonym_graph",
                    "synonyms_path": "custom/products/autophrase-synonyms.txt",
                    "lenient": "true"
                  },
                  "text_general_3_stemmer_override_filter_query": {
                    "type": "stemmer_override",
                    "rules_path": "custom/products/stemdict.txt"
                  },
                  "text_general_3_stemmer_override_filter_index": {
                    "type": "stemmer_override",
                    "rules_path": "custom/products/stemdict.txt"
                  },
                  "text_general_5_word_delimiter_graph_filter_index": {
                    "split_on_numerics": "false",
                    "type_table_path": "custom/products/word-delim-types.txt",
                    "generate_word_parts": "true",
                    "preserve_original": "true",
                    "catenate_words": "true",
                    "generate_number_parts": "false",
                    "catenate_all": "true",
                    "split_on_case_change": "true",
                    "type": "word_delimiter_graph",
                    "catenate_numbers": "true"
                  },
                  "text_general_6_stop_filter_index": {
                    "ignore_case": "true",
                    "type": "stop",
                    "stopwords_path": "custom/products/stopwords.txt"
                  }
                },
                "char_filter": {
                  "text_general_1_pattern_replace_char_filter_query": {
                    "pattern": """((?:[0-9]{1,2})|(?:[1-4]\/[2468]))(?:(?:[ -])([1-4]\/[2468]))?(?:-(?:in|ft))?(?: )?(?:[x|X])(?: )?((?:[0-9]{1,2})|(?:[1-4]\/[2468]))(?:(?:[ -])([1-4]\/[2468]))?(?:-(?:in|ft))?""",
                    "type": "pattern_replace",
                    "replacement": "$1$2//$3$4"
                  },
                  "text_general_1_pattern_replace_char_filter_index": {
                    "pattern": """((?:[0-9]{1,2})|(?:[1-4]\/[2468]))(?:(?:[ -])([1-4]\/[2468]))?(?:-(?:in|ft))?(?: )?(?:[x|X])(?: )?((?:[0-9]{1,2})|(?:[1-4]\/[2468]))(?:(?:[ -])([1-4]\/[2468]))?(?:-(?:in|ft))?""",
                    "type": "pattern_replace",
                    "replacement": "$1$2//$3$4"
                  },
                  "text_general_0_pattern_replace_char_filter_query": {
                    "pattern": """((?:[0-9]{1,2})|(?:[1-4]\/[2468]))(?:(?:[ -])([1-4]\/[2468]))?(?:-(?:in|ft))?(?: )?(?:[x|X])(?: )?((?:[0-9]{1,2})|(?:[1-4]\/[2468]))(?:(?:[ -])([1-4]\/[2468]))?(?:-(?:in|ft))?(?: )?(?:[x|X])(?: )?((?:[0-9]{1,2})|(?:[1-4]\/[2468]))(?:(?:[ -])([1-4]\/[2468]))?(?:-(?:in|ft))?""",
                    "type": "pattern_replace",
                    "replacement": "$1$2//$3$4//$5$6 $1$2//$3$4 $3$4//$5$6 $1$2//$5$6"
                  },
                  "text_general_0_pattern_replace_char_filter_index": {
                    "pattern": """((?:[0-9]{1,2})|(?:[1-4]\/[2468]))(?:(?:[ -])([1-4]\/[2468]))?(?:-(?:in|ft))?(?: )?(?:[x|X])(?: )?((?:[0-9]{1,2})|(?:[1-4]\/[2468]))(?:(?:[ -])([1-4]\/[2468]))?(?:-(?:in|ft))?(?: )?(?:[x|X])(?: )?((?:[0-9]{1,2})|(?:[1-4]\/[2468]))(?:(?:[ -])([1-4]\/[2468]))?(?:-(?:in|ft))?""",
                    "type": "pattern_replace",
                    "replacement": "$1$2//$3$4//$5$6 $1$2//$3$4 $3$4//$5$6 $1$2//$5$6"
                  }
                },
                "normalizer": {
                  "product_id_concepts_normalizer": {
                    "filter": [
                      "lowercase"
                    ],
                    "type": "custom"
                  }
                },
                "analyzer": {
                  "lowercase_analyzer": {
                    "filter": [
                      "lowercase"
                    ],
                    "tokenizer": "keyword"
                  },
                  "text_general_query_analyzer": {
                    "filter": [
                      "lowercase",
                      "text_general_2_autophrase_synonym_graph_filter_query",
                      "text_general_3_stemmer_override_filter_query",
                      "kstem",
                      "text_general_5_synonym_graph_filter_query",
                      "text_general_7_stop_filter_query"
                    ],
                    "char_filter": [
                      "text_general_0_pattern_replace_char_filter_query",
                      "text_general_1_pattern_replace_char_filter_query"
                    ],
                    "tokenizer": "whitespace"
                  },
                  "text_general_index_analyzer": {
                    "filter": [
                      "lowercase",
                      "text_general_2_autophrase_synonym_graph_filter_index",
                      "text_general_5_word_delimiter_graph_filter_index",
                      "text_general_3_stemmer_override_filter_index",
                      "kstem",
                      "text_general_6_stop_filter_index"
                    ],
                    "char_filter": [
                      "text_general_0_pattern_replace_char_filter_index",
                      "text_general_1_pattern_replace_char_filter_index"
                    ],
                    "tokenizer": "whitespace"
                  }
                }
              },
              "knn.derived_source": {
                "enabled": "true"
              }
            }
          },
          "mappings": {
            "_source": {
              "excludes": [
                "description_dense_vector"
              ]
            },
            "dynamic_templates": [],
            "properties": {
              "product_id": {
                "store": "false",
                "type": "keyword",
                "fields": {
                  "concepts": {
                    "normalizer": "product_id_concepts_normalizer",
                    "store": "false",
                    "type": "keyword",
                    "doc_values": "true"
                  }
                },
                "doc_values": "true"
              },
              "id": {
                "store": "false",
                "type": "keyword",
                "doc_values": "false"
              },
              "description_dense_vector": {
                "method": {
                  "engine": "faiss",
                  "name": "hnsw",
                  "parameters": {
                    "ef_search": 170,
                    "ef_construction": 256,
                    "encoder": {
                      "name": "sq"
                    },
                    "m": 32
                  }
                },
                "space_type": "cosinesimil",
                "type": "knn_vector",
                "dimension": 768
              },
              "description": {
                "search_analyzer": "text_general_query_analyzer",
                "position_increment_gap": "100",
                "analyzer": "text_general_index_analyzer",
                "store": "false",
                "type": "text"
              },
              "multifield_text": {
                "type": "text"
              }
            }
          }
        },
        "composed_of": []
      }
    }
  ]
}

Hi @pablo, @viktari Thank you for your support

Thank you for all the support