Hello All,

I am wondering how to rank exact match higher than the nGram matches.

For example:

search string: *abcd*
results - abcd, abcde, abcdegl 

not in a particular order.

But I want to rank 'abcd' higher than the rest. Is it possible??
I am adding my mappings, analyzers and query below.


mapping for a particular field:

{
     'type': 'multi_field',
     'fields': {
                'name': {
                    'type': 'string',
                    'search_analyzer': 'search_analyzer',
                    'index_analyzer': 'index_analyzer',
                    'include_in_all': True
                },
                'untouched': {
                    'type': 'string',
                    'index': 'not_analyzed',
                    'include_in_all': False,
                },
                'standard': {
                    'type': 'string',
                    'analyzer': 'search_analyzer',
                    'include_in_all': False
                }
      },
}

My analyzers:

{
        'settings': {
            'analysis': {
                'filter': {
                    'substring': {
                        'type': 'nGram',
                        'min_gram': 1,
                        'max_gram': 25
                    }
                },
                'analyzer': {
                    'index_analyzer': {
                        'type': 'custom',
                        'tokenizer': 'standard',
                        'filter': [
                            'standard',
                            'lowercase',
                            'asciifolding',
                            'substring'
                        ]
                    },
                    'search_analyzer': {
                        'type': 'custom',
                        'tokenizer': 'standard',
                        'filter': [
                            'standard',
                            'lowercase',
                            'asciifolding'
                        ]
                    }
                }
            }
        }
    }


query (I am searching in all fields'_all')

{
        'query': {
            'query_string': {
                'query': 'abcd',
                'analyze_wildcard': True,
                'analyzer': 'search_analyzer',
                'default_operator': 'AND'
            }
        },
}

Thanks,
Nikhil

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/3bd861ff-d854-45ab-bb4f-471a7d34b8cc%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to