Saturday, 19 October 2019

As You Add And Delete Documents

As You Add And Delete Documents





This section describes how to configure suggesters so you can retrieve suggestions. Suggestions are possible matches for an incomplete search query鈥攖hey enable you to display likely matches before users finish typing their queries. In Amazon CloudSearch, suggestions are based on the contents of a particular text field. When you request suggestions, Amazon CloudSearch finds all of the documents whose values in the suggester field start with the specified query string鈥攖he beginning of the field must match the query string to be considered a match. The return data includes the field value and document ID for each match. You can configure suggesters to find matches for the exact query string, or to perform approximate string matching (fuzzy matching) to correct for typographical errors and misspellings. For more information about the suggest API, see Suggest in the Search API. When you configure a suggester, you must specify the name of the text field you want to search for possible matches and a unique name for the suggester.





Fields used for suggestions must be return enabled. Only the first 512 bytes of data in the field are used to generate suggestions. Suggester names must begin with a letter and be at least three and no more than 64 characters long. The suggester name is specified in the query string when you retrieve suggestions, so it's best to use short names. The name score is reserved and cannot be used as a suggester name. FuzzyMatching鈥擸ou can set the level of fuzziness allowed when suggesting matches for a string to none, low, or high. With none, the specified string is treated as an exact prefix. With low, suggestions must differ from the specified string by no more than one character. With high, suggestions can differ by up to two characters. The default is none. SortExpression鈥擸ou can configure this expression to compute a score for each suggestion to control how they are sorted.





To sort suggestions using a numeric field or existing expression, simply specify the name of the field or expression. If no expression is configured for the suggester, the suggestions are sorted in alphabetical order. Note that an expression defined within a suggester cannot be referenced in search requests or other expressions. If want to use an expression for other purposes, add it to your domain configuration and reference it by name from the suggester. For more information about expressions, see Configuring Expressions. If you want to get suggestions from multiple text fields, you define a suggester for each field and submit separate suggestion requests to get matches from each suggester. You can configure up to ten suggesters. Suggesters can consume significant amounts of memory and disk space, particularly if you use text-heavy source fields and set fuzzy matching to high. Instead of configuring suggesters to use all possibilities from all documents, consider indexing the most popular 1,000 or 10,000 search queries and configuring suggesters to use those. You can store the queries in a separate Amazon CloudSearch index or in a field used only for suggestions.





The easiest way to define suggesters is through the Suggesters page in the Amazon CloudSearch console. You can also define suggesters using the AWS SDKs or AWS CLI. After you add a suggester to your search domain, you must run indexing before you can use it to retrieve suggestions. As you add and delete documents, you must periodically rebuild your index to update the suggestions. Suggestions won't reflect added or deleted documents until you call IndexDocuments. You can easily add, update, and delete suggesters through the Amazon CloudSearch console. 2. In the navigation pane, click the name of the domain, and then click the domain's Suggesters link. 3. In the Suggesters pane, click the Add a New Suggester button. The button is below the list of suggesters configured for the domain. 4. Enter a name for the new suggester in the Name field. 5. Specify the text field you want to use for suggestions in the Source field. 6. If you want to include suggestions that correct for minor misspellings or typos, set the Fuzzy Matching option to low or high.





When set to low, the suggestions include terms that differ from the user query string by a single character. When set to high, the suggestions include terms that differ by up to two characters. 7. If you want to control how the suggestions are sorted, enter a numeric expression in the Sort Expression field. The expression can simply be the name of the numeric field you want to use to sort the suggestions, the name of an existing expression, or any valid expression. For more information about expressions, see Configuring Expressions. 8. Click Submit to save your changes. 9. When you are done configuring suggesters for your search domain, you must re-index your domain before you can use the suggesters. To run indexing, go to the domain dashboard and click the Run Indexing button on the domain dashboard. 2. In the Navigation pane, click the name of the domain, and then click the domain's Suggesters link.