Search code examples
databasesearch-engine

get exact words with Query template OpenSearchServer


I am using OpenSearchServer (community edition) v1.2.4-rc3 - stable - rev 1474 - build 802 on windows server 2008 r2. I need a query template that returns the exact words. For example when someone search for "PHP" it returns all sentences that starts with "PHP" not match between the words. I've this query template expression:($$). When I search for PHP it returns

PHP
PHP Free
What is PHP

Notice that the 3rd line has word "PHP" in the end. But I want that query returns that has my required word only in the start of line. Please suggest me a query template for this


Solution

  • You have to change the tokenizer used by the analyzer. The field "expression" is related to an analyzer. Here is the process:

    • Get the name of the analyzer in the "Schema/Field" tab panel.
    • In the "Schema/Analyzer" tab panel, edit the analyzer.
    • Change the Tokenize from "StandardTokenizer" to "KeywordTokenizer".
    • Re-index your data

    It should work now.