Skip to content

SuggestOption - Payload - How To Index Data In The Payload #984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mickdelaney opened this issue Oct 13, 2014 · 5 comments
Closed

SuggestOption - Payload - How To Index Data In The Payload #984

mickdelaney opened this issue Oct 13, 2014 · 5 comments

Comments

@mickdelaney
Copy link

Hi,

I want to index the id of a entity that i'm using the completion suggester with.
the name will be the text & then a payload object would contain its id to use when selected.

as shown here: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html

is that available in NEST at the moment?

regards

@mickdelaney
Copy link
Author

For reference I figured it out:

I just created an object:

[JsonObject]
public class SuggestModel
{
[JsonProperty("input")]
public IEnumerable Input { get; set; }

    [JsonProperty("output")]
    public string Output { get; set; }

    [JsonProperty("payload")]
    public object Payload { get; set; }
}

and indexed that using the following mapping:

[ElasticProperty(
Name = "suggested_company",
Type = FieldType.Completion,
IndexAnalyzer = "simple",
SearchAnalyzer = "simple"
)]
public SuggestModel SuggestedCompany { get; set; }

@gmarz
Copy link
Contributor

gmarz commented Oct 13, 2014

@mickdelaney

FYI- we just added this recently: https://github.com/elasticsearch/elasticsearch-net/blob/develop/src/Nest/Domain/Suggest/SuggestField.cs

Which you can get if you're willing to update to our CI package on myget. Otherwise, using your own object works fine.

Mpdreamz added a commit that referenced this issue Dec 8, 2014
gmarz added a commit that referenced this issue Dec 8, 2014
@MattMinke
Copy link

Follow up question. Should SuggestField.Input be a string or an IEnumerable like @mickdelaney has. If its suppose to be a string then how do you handle multiple inputs?

@gmarz
Copy link
Contributor

gmarz commented Feb 25, 2015

@Minx-SigEp it should be an IEnumerable, but would be a breaking change. We have this issue open #1220 to address it in 2.0.

For now, you can just implement your own suggest object.

@bgiromini
Copy link
Contributor

@mickdelaney Here is how I indexed the completion suggestions:

http://stackoverflow.com/a/21887982/593214

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants