Skip to content
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

Collate option in PhraseSuggester should allow returning phrases with no matching docs #6929

Merged
merged 1 commit into from
Jul 22, 2014

Conversation

areek
Copy link
Contributor

@areek areek commented Jul 18, 2014

The new option return_all_phrases in PhraseSuggester collate will allow the user to control whether all the generated suggestions would be returned. Setting the option will have an additional field match_exists in the suggestion options, indicating if there were matched documents for the phrase. The default value for this is false.

Currently the request would look as follows:

curl -XPOST 'localhost:9200/_search' -d {
   "suggest" : {
     "text" : "Xor the Got-Jewel",
     "simple_phrase" : {
       "phrase" : {
         "field" :  "bigram",
         "size" :   1,
         "direct_generator" : [ {
           ...
         } ],
         "collate": {
           "query": { 
              ...
           },
           "return_all_phrases": true
         }
       }
     }
   }
 }

and the response looks as follows (only when return_all_phrases is set to true)

"suggest" : {
    "simple_phrase" : [ {
      "text" : "Xor the Got-Jewel",
      "offset" : 0,
      "length" : 17,
      "options" : [ {
        "text" : ...,
        "highlighted": ...,
        "score" : ...,
        "match_exists" : true
      }, {
        "text" : ...,
        "highlighted": ...,
        "score" : ..,
        "match_exists": false
      } ]
    } ]
  }

Closes #6927

@areek areek added the review label Jul 18, 2014
@@ -195,6 +200,7 @@ curl -XPOST 'localhost:9200/_search' -d {
},
"params": {"field_name" : "title"}, <3>
"preference": "_primary", <4>
"return_all_phrases": true <5>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we make this part of the "collate" : {} object? I think we can just do something like:

"collate" : {
  "prune" : true|false,
  "query" : {...}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! prune is a much better name, changed

@s1monw
Copy link
Contributor

s1monw commented Jul 22, 2014

I left some naming comments

@s1monw s1monw removed the review label Jul 22, 2014
@areek
Copy link
Contributor Author

areek commented Jul 22, 2014

Thanks for the review, @s1monw! I updated the PR with the feedback.

@areek
Copy link
Contributor Author

areek commented Jul 22, 2014

Now the request looks like:

curl -XPOST 'localhost:9200/_search' -d {
   "suggest" : {
     "text" : "Xor the Got-Jewel",
     "simple_phrase" : {
       "phrase" : {
         "field" :  "bigram",
         "size" :   1,
         "direct_generator" : [ {
           ...
         } ],
         "collate": {
           "query": { 
              ...
           },
           "prune": true
         }
       }
     }
   }
 }

and the response:

"suggest" : {
    "simple_phrase" : [ {
      "text" : "Xor the Got-Jewel",
      "offset" : 0,
      "length" : 17,
      "options" : [ {
        "text" : ...,
        "highlighted": ...,
        "score" : ...,
        "collate_match" : true
      }, {
        "text" : ...,
        "highlighted": ...,
        "score" : ..,
        "collate_match": false
      } ]
    } ]
  }

If the collate option is not set, then collate_match is not included in the response.

@s1monw
Copy link
Contributor

s1monw commented Jul 22, 2014

LGTM

…o matching docs

A new option `prune` has been added to allow users to control phrase suggestion pruning when `collate`
is set. If the new option is set, the phrase suggestion option will contain a boolean `collate_match`
indicating whether the respective result had hits in collation.

CLoses elastic#6927
@areek areek merged commit f39d4e1 into elastic:master Jul 22, 2014
@areek areek deleted the enhancement/6927 branch July 22, 2014 21:25
@clintongormley clintongormley changed the title PhraseSuggester: Collate option should allow returning phrases with no matching docs Suggesters: Collate option in PhraseSuggester should allow returning phrases with no matching docs Sep 11, 2014
@clintongormley clintongormley added the :Search Relevance/Suggesters "Did you mean" and suggestions as you type label Jun 7, 2015
@clintongormley clintongormley changed the title Suggesters: Collate option in PhraseSuggester should allow returning phrases with no matching docs Collate option in PhraseSuggester should allow returning phrases with no matching docs Jun 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PhraseSuggester: Collate option should allow returning phrases with no matching docs
3 participants