Problem with Elastic Search and Autocomplete


(Robert Velton) #1

I am currently using version 1.5.2 in production and autocomplete is working fine. However, I am trying to upgrade my dev environment to 2.4.1 and am running into the following issue.

When a user searches for "San Di", they will get results for San Diego.
However, if they search for "San D", they will get no results for San Diego.

Here is my query:

Array
(
    [query] => Array
        (
            [filtered] => Array
                (
                    [filter] => Array
                        (
                            [and] => Array
                                (
                                    [0] => Array
                                        (
                                            [type] => Array
                                                (
                                                    [value] => category
                                                )
                                        )
                                )
                        )
                    [query] => Array
                        (
                            [multi_match] => Array
                                (
                                    [query] => san d
                                    [fields] => Array
                                        (
                                            [0] => primaryText^3
                                            [1] => secondaryText
                                        )
                                    [type] => phrase_prefix
                                )
                        )
                )
        )
    [sort] => Array
        (
            [0] => Array
                (
                    [contentScore] => desc
                )
            [1] => Array
                (
                    [contentTimestamp] => asc
                )
        )
    [size] => 5
)

Here are my mappings:

public static $optimizedGenericMapping = array(
    "_source" => array(
        "enabled" => true
    ),
    "properties" => array(
        "primaryText" => array(
            "type" => "string",
            "search_analyzer" => "str_search_analyzer",
            "index_analyzer" => "str_index_analyzer"
        ),
        "secondaryText" => array(
            "type" => "string",
            "search_analyzer" => "str_search_analyzer",
            "index_analyzer" => "str_index_analyzer"
        ),
        "contentTitle" => array(
            "type" => "string"
        ),
        "contentSubtitle" => array(
            "type" => "string"
        ),
        "contentLocation" => array(
            " type" => "geo_point"
        )
    )
);

Here is my index settings:

    $dsl = array(
        'index' => array(
            'analysis' => array(
                'analyzer' => array(
                    'str_search_analyzer' => array(
                        'tokenizer' => 'keyword',
                        'filter' => array(
                            'lowercase'
                        )
                    ),
                    'str_index_analyzer' => array(
                        'tokenizer' => 'keyword',
                        'filter' => array(
                            'lowercase',
                            'substring'
                        )
                    ),
                    'autocomplete' => array(
                        'type' => 'custom',
                        'tokenizer' => 'standard',
                        'filter' => array(
                            'standard',
                            'lowercase',
                            'stop',
                            'kstem',
                            'ngram'
                        )
                    )
                ),
                'filter' => array(
                    'substring' => array(
                        'type' => 'ngram',
                        'min_gram' => 1,
                        'max_gram' => 20
                    )
                )
            )
        )
    );

Totally stuck on this one and not sure what I am supposed to do at this point. Any help would be greatly appreciated, thanks.


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.