I have a very weird situation with opensearch...
This document:
{
name: 'Andrew Jones',
contact_name: nil,
address_nil,
account_id: 1234
}
is NOT searchable with this query
{:bool=>
{:should=>
[{:query_string=>
{:query=>"andrew jones",
:fields=>["name"],
:type=>:best_fields,
:allow_leading_wildcard=>true,
:default_operator=>"AND",
:minimum_should_match=>1}}],
:minimum_should_match=>1,
:filter=>[{:term=>{:account_id=>1234}}]}}
but if I add the contact_name or the address into fhe fields list, then it is searchable, the above query will find the record if it is written as...
{:bool=>
{:should=>
[{:query_string=>
{:query=>"andrew jones",
:fields=>["name", "contact_name"],
:type=>:best_fields,
:allow_leading_wildcard=>true,
:default_operator=>"AND",
:minimum_should_match=>1}}],
:minimum_should_match=>1,
:filter=>[{:term=>{:account_id=>1234}}]}}
Could anyone please advise what could be the issue?, name is a edge-ngram field this is the settings of that index
{"customers"=>
{"settings"=>
{"index"=>
{"replication"=>{"type"=>"DOCUMENT"},
"refresh_interval"=>"60s",
"number_of_shards"=>"1",
"provided_name"=>"customers",
"creation_date"=>"1701847737857",
"analysis"=>
{"filter"=>
{"edge_ngram_filter"=>
{"type"=>"edge_ngram", "min_gram"=>"1", "max_gram"=>"20"}},
"analyzer"=>
{"autocomplete"=>
{"filter"=>["lowercase", "edge_ngram_filter"],
"type"=>"custom",
"tokenizer"=>"standard"}}},
"number_of_replicas"=>"2",
"uuid"=>"xxxxxxxxx",
"version"=>{"created"=>"136327827"}}}}}
i tried "explain" and the result is:
{"_index"=>"customers",
"_id"=>"477323",
"matched"=>false,
"explanation"=>
{"value"=>0.0,
"description"=>
"Failure to meet condition(s) of required/prohibited clause(s)",
"details"=>
[{"value"=>0.0,
"description"=>
"no match on required clause ((+name:andrew +name:jones)~1)",
"details"=>
[{"value"=>0.0,
"description"=>
"Failure to match minimum number of optional clauses: 1",
"details"=>
[{"value"=>11.455513,
"description"=>
"weight(name:andrew in 669578) [PerFieldSimilarity], result of:",
"details"=>
[{"value"=>11.455513,
"description"=>
"score(freq=1.0), computed as boost * idf * tf from:",
"details"=>
[{"value"=>2.2, "description"=>"boost", "details"=>[]},
{"value"=>7.5547304,
"description"=>
"idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from:",
"details"=>
[{"value"=>5382,
"description"=>"n, number of documents containing term",
"details"=>[]},
{"value"=>10279256,
"description"=>"N, total number of documents with field",
"details"=>[]}]},
{"value"=>0.6892438,
"description"=>
"tf, computed as freq / (freq + k1 * (1 - b + b * dl / avgdl)) from:",
"details"=>
[{"value"=>1.0,
"description"=>
"freq, occurrences of term within document",
"details"=>[]},
{"value"=>1.2,
"description"=>"k1, term saturation parameter",
"details"=>[]},
{"value"=>0.75,
"description"=>"b, length normalization parameter",
"details"=>[]},
{"value"=>2.0,
"description"=>"dl, length of field",
"details"=>[]},
{"value"=>11.9311695,
"description"=>"avgdl, average length of field",
"details"=>[]}]}]}]},
{"value"=>8.6221695,
"description"=>
"weight(name:jones in 669578) [PerFieldSimilarity], result of:",
"details"=>
[{"value"=>8.6221695,
"description"=>
"score(freq=1.0), computed as boost * idf * tf from:",
"details"=>
[{"value"=>2.2, "description"=>"boost", "details"=>[]},
{"value"=>5.686185,
"description"=>
"idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from:",
"details"=>
[{"value"=>34872,
"description"=>"n, number of documents containing term",
"details"=>[]},
{"value"=>10279256,
"description"=>"N, total number of documents with field",
"details"=>[]}]},
{"value"=>0.6892438,
"description"=>
"tf, computed as freq / (freq + k1 * (1 - b + b * dl / avgdl)) from:",
"details"=>
[{"value"=>1.0,
"description"=>
"freq, occurrences of term within document",
"details"=>[]},
{"value"=>1.2,
"description"=>"k1, term saturation parameter",
"details"=>[]},
{"value"=>0.75,
"description"=>"b, length normalization parameter",
"details"=>[]},
{"value"=>2.0,
"description"=>"dl, length of field",
"details"=>[]},
{"value"=>11.9311695,
"description"=>"avgdl, average length of field",
"details"=>[]}]}]}]}]}]},
{"value"=>0.0,
"description"=>"match on required clause, product of:",
"details"=>
[{"value"=>0.0, "description"=>"# clause", "details"=>[]},
{"value"=>1.0,
"description"=>"account_id:[1234 TO 1234]",
"details"=>[]}]}]}}