Search code examples
databasesearch-engine

How do I access OpenSearchServer database fields?


I am using OpenSearchServer v1.2.4. I want to access OpenSearchServer database field like "autocomplete" or Spell check etc. How Can i do that? The OpenSearchServer api only provides title, meta, url fields and some others via XML. Please suggest me query/search pattern to get autocomplete field.


Solution

  • You can easily control the returned fields by editing the query. To do that, go to the query tab panel.

    Spellchecking

    To activate the spellcheck, edit the "search" query and go to the spellcheck tab panel. If you are using the web template, use the field "contentExact" or "titleExact". The spellcheck module will build a dictionary by extracting the words present in this field. There is three algorithms available: Levensthein, Jaro-Winkler, NGramDistance.

    As soon as you have set up the spellcheck settings and saved the query, you will be able to use it using the XML over HTTP API. Most of the time, the XML will include spellcheck suggestions. You have to decide when you show the suggestion to the users. You may display the suggestions when the search returns no document.

    Autocompletion

    The role of the "autocomplete" field is to collect all the expressions available in the indexed documents (web pages).

    Here is a common way to build an autocompletion feature:

    • Create a new empty index with the following fields:
      • Expression: indexed, stored, the analyzer describer in the next point.
      • freq: indexed, not stored.
    • Create a text analyzer for the expression field, with the following parameters:
      • Tokenizer: StandardTokenizer
      • In the filter list, add:
        • a LowerCaseFilter
        • a EgdeNGramFilter (Min gram size: 1 - Max gram size: 50 - Edge side: front)
    • Create a sheduler job. It will populate the new index with the collected expressions at regular interval (Example: once a day). The typical task and parameters are:
      • Add a "Delete query" task: Query::
      • Add a "Pull terms" task:
        • Source field name: autocomplete
        • Index source: The name of the web index
        • Term field name: expression
        • Frequency field name: freq
        • Minimum frequency: 1
        • Frequency pad: 9
      • Add an "Index - optimize" task.
    • Create a new request with the following parameters:
      • Pattern query: expression:($$)
      • Returned field: expression
      • Sorted fields: freq descending, score descending
    • Integrate the autocompletion user interface by using the new query.