Skip to content

Search phrase suggester collate query (ElasticSearch 2.x) #2176

@harvzor

Description

@harvzor

Hi, I have been looking into using the collate option of a phrase suggestion to filter out suggestions that would not produce search query results. There is some documentation here: https://www.elastic.co/guide/en/elasticsearch/client/net-api/2.x/suggest-usage.html

I see that the query currently needs to be inline:

 .Collate(c => c
     .Query(q => q
         .Inline("{ \"match\": { \"{{field_name}}\": \"{{suggestion}}\" }}")
         .Params(p => p.Add("field_name", "title"))
     )
     .Prune()
)

However, this means that I lose any Intellisense, and if I change my mappings in my index, no errors will be thrown until query time.

I can see that there is another another option instead of the inline search descriptor. It appears I can use a previously indexed query by using the .Indexed() option:

 .Collate(c => c
     .Query(q => q
         .Indexed(/* what goes here? */)
     )
     .Prune()
)

Though there doesn't seem to be any documentation on this and no tests either. Can someone point me in the right direction?

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions