The mapping looks good to me. Please refer to the following link on the 
impact of prioritizing-clauses 
<http://www.elastic.co/guide/en/elasticsearch/guide/current/multi-query-strings.html#prioritising-clauses>
 
on bool query.


So looks like you want to score the award_name matches higher. so you can 
keep that in seperate should clause. And depends on how the other field 
matches or partial matches should contribute to the total score of 
relevance you can group them and keep it in the same level or sub level of 
the bool query.

"query" : {
      "bool" : {
         "should" : [
            {
               "match" : {
                  "award_name" : {
                     "boost" : 4,
                     "query" : "navy meritorious"
                  }
               }
            },
{ "bool":  { 
"should": [
  { "match": { "ribbon.standard.sku": "navy meritorious" }},
  { "match": { "search.abbrev_long": "navy meritorious"}}
  ...
]
}}

Also the order of the terms in the query doesn't matter, because the search 
analyzer splits "meritorious navy" to two tokens as seen by the below query
GET /<index_name>/_analyze?analyzer=full_name 
{
  "navvy meritorious"
}
to 
     {
         "token": "navvy",
         "start_offset": 5,
         "end_offset": 10,
         "type": "<ALPHANUM>",
         "position": 1
      },
      {
         "token": "meritorious",
         "start_offset": 11,
         "end_offset": 22,
         "type": "<ALPHANUM>",
         "position": 2
      } 

Addressing your next question on boosting score if more query terms appear 
on the award_name field,  that's due to bool match query being field 
centric rather than terms centric.
please refer to the link 
<http://www.elastic.co/guide/en/elasticsearch/guide/current/_cross_fields_entity_search.html#_a_naive_approach>.
 
Basically the bool query you have here is same as multi_match query with 
type set to "most_fields". As it's being field-centric query that faces 
three common issues (as listed down in 
http://www.elastic.co/guide/en/elasticsearch/guide/current/field-centric.html) 
which is exactly the problem statement that you are trying to resolve. 

You may verify the same by enclosing your current query with _validate 
option
 GET /<index>/<type>/_validate/query?explain{
 ...
 }

So you may want to try out term-centric query (i.e) cross_fields query 
(http://www.elastic.co/guide/en/elasticsearch/guide/current/_cross_fields_queries.html).
 
Also you can take advantage of per-field boosting of this query to boost 
award_name matches.

    "query": {
        "multi_match": {
            "query":       "navy meritorious",
            "type":        "cross_fields",
            "fields":      [ "award_name^2", "ribbon.standard.sku", 
"search.abbrev_long", "search.data_code", "search.abbrev_short" ..] 
        }
    }

So you may have your final query in a single multi_match   
GET /<index>/<type>/_validate/query?explain
{
  "query": {
    "multi_match": {
      "query": "navy meritorious",
      "type": "cross_fields",
      "fields": [
        "award_name^4",
        "ribbon.standard.sku^2",
        "search.abbrev_long^2",
        "search.data_code^2",
        "search.abbrev_short^2",
        "award_name.partial^2",
        "ribbon.standard.sku.partial",
        "search.abbrev_long.partial",
        "search.data_code.partial",
        "search.abbrev_short.partial"
      ]
    }
  }
}

or you can combine multiple multi_match (cross_fields) queries with bool 
again based on your best needs.
GET /<index>/<type>/_validate/query?explain
{
  "query": {
    "bool": {
      "should": [
        {
          "multi_match": {
            "query": "navy meritorious",
            "type": "cross_fields",
            "fields": [
              "award_name^2",
              "ribbon.standard.sku",
              "search.abbrev_long",
              "search.data_code",
              "search.abbrev_short"
            ],
            "boost": 2
          }
        },
        {
          "bool": {
            "should": [
              {
                "multi_match": {
                  "query": "navy meritorious",
                  "type": "cross_fields",
                  "fields": [
                    "award_name.partial^2",
                    "ribbon.standard.sku.partial",
                    "search.abbrev_long.partial",
                    "search.data_code.partial",
                    "search.abbrev_short.partial"
                  ]
                }
              }
            ]
          }
        }
      ]
    }
  }
}

Hope that helps.

On Friday, April 24, 2015 at 5:18:12 PM UTC-7, Zelfapp wrote:
>
> I also don't want the order to matter. e.g. if I typed "meritorious navy" 
> vs. "navy meritorious" I should get nearly or exactly the same results.
>
> On Friday, April 24, 2015 at 5:16:18 PM UTC-7, Zelfapp wrote:
>
> This is my php array mapping for my index and type. Below that is the 
> query I'm currently using and an example of results and the issue I'm not 
> sure how to fix in either my mapping or in my search query.
>
> *Summary of mapping:*
>
>    - We have partial matching on the award_name field, which is an 
>    alphanumeric string.
>    - We also boost exact matches on the award_name field .
>    - On the "sku" fields we do the same partial matching and exact 
>       matches.
>       - On the "search" fields we do the same partial matching and exact 
>       matches.
>       
>
> $params = [
>             'index' => 'ezr_v1',
>             'body' => [
>                 'settings' => [ 
>                     'number_of_shards' => 3,
>                     'number_of_replicas' => 1,
>                     'analysis' => [
>                         'filter' => [
>                             'name_ngrams' => [
>                                 'side' => 'front',
>                                 'max_gram' => '10',
>                                 'min_gram' => 1,
>                                 'type' => 'edgeNGram'
>                             ]
>                         ],
>                         'analyzer' => [
>                             'full_name' => [
>                                 'filter' => [
>                                     'standard',
>                                     'lowercase'
>                                 ],
>                                 'type' => 'custom',
>                                 'tokenizer' => 'standard'
>                             ],
>                             'partial_name' => [
>                                 'filter' => [
>                                     'standard',
>                                     'lowercase',
>                                     'name_ngrams'
>                                 ],
>                                 'type' => 'custom',
>                                 'tokenizer' => 'standard'
>                             ]
>                         ]
>                     ]
>                 ],
>                 'mappings' => [ 
>                     'ezr_' [    
>                         '_all' => [ 
>                             'enabled' => false
>                         ],
>                         'properties' => [
>                             'award_name' => [
>                                 'fields' => [
>                                     'partial' => [
>                                         'search_analyzer' => 'full_name',
>                                         'index_analyzer' => 'partial_name'
> ,
>                                         'type' => 'string'
>                                     ],
>                                     'award_name' => [
>                                         'type' => 'string',
>                                         'analyzer' => 'full_name'
>                                     ]
>                                 ],
>                                 'type' => 'multi_field'
>                             ],
>                             'medal' => [
>                                 'properties' => [
>                                    'anodized' => [
>                                         'properties' => [
>                                             'sku' => [
>                                                 'fields' => [
>                                                    'partial' => [
>                                                         'search_analyzer' 
> => 'full_name',
>                                                         'index_analyzer' 
> => 'partial_name',
>                                                         'type' => 'string'
>                                                    ],
>                                                    'sku' => [
>                                                        'type' => 'string',
>                                                        'analyzer' => 
> 'full_name'
>                                                    ]
>                                                 ],
>                                                 'type' => 'multi_field'
>                                             ]
>                                         ]
>                                    ],
>                                    'standard' => [
>                                         'properties' => [
>                                             'sku' => [
>                                                 'fields' => [
>                                                    'partial' => [
>                                                         'search_analyzer' 
> => 'full_name',
>                                                         'index_analyzer' 
> => 'partial_name',
>                                                         'type' => 'string'
>                                                    ],
>                                                    'sku' => [
>                                                        'type' => 'string',
>                                                        'analyzer' => 
> 'full_name'
>                                                    ]
>                                                 ],
>                                                 'type' => 'multi_field'
>                                             ]
>                                         ]
>                                    ]
>                                 ]
>                             ],
>                             'mini' => [
>                                 'properties' => [
>                                    'anodized' => [
>                                         'properties' => [
>                                             'image' => [
>                                                 'type' => 'string',
>                                                 'index' => 'no'
>                                             ],
>                                             'price' => [
>                                                 'type' => 'string',
>                                                 'index' => 'no'
>                                             ],
>                                             'product_name' => [
>                                                 'type' => 'string',
>                                                 'index' => 'no'
>                                             ],
>                                             'sku' => [
>                                                 'fields' => [
>                                                    'partial' => [
>                                                         'search_analyzer' 
> => 'full_name',
>                                                         'index_analyzer' 
> => 'partial_name',
>                                                         'type' => 'string'
>                                                    ],
>                                                    'sku' => [
>                                                        'type' => 'string',
>                                                        'analyzer' => 
> 'full_name'
>                                                    ]
>                                                 ],
>                                                 'type' 
>
> ...

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/f16962f0-a3fc-4da9-afb9-b00d2b88920f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to