Searching from the full text

Full-text queries can work on unstructured text fields. These queries are aware of the analysis process. Full-text queries apply the analyzer on the search terms before performing the actual search operation. That determines the right analyzer to be applied by first checking whether a field-level search_analyzer is defined, and then by checking whether a field-level analyzer is defined. If analyzers at the field level are not defined, it tries the analyzer defined at the index level.

Full-text queries are thus aware of the analysis process on the underlying field and apply the right analysis process before forming actual search queries. These analysis-aware queries are also called high-level queries. Let's understand how the high-level query flow works.

Here, we can see how one high-level query on the title field will be executed. Remember from our index definition earlier that the title field is of the text type. At indexing time, the value is analyzed using the analyzer for the field. In this case, it was a Standard Analyzer, and hence the inverted index contains all of the broken down terms, such as gods, heroes, rome, and so on, as depicted in the following figure:

Figure 3.3: High-level query flow

At query time (see the right-hand half of the figure), we issue a match query, which is a high-level query. We will cover match queries later in this section. The search terms passed to a match query are analyzed using standard analyzer. The individual terms after applying standard analyzer are then used to generate individual term-level queries.

The example here results in multiple term queries—one for each term after applying the analyzer. The original search term was gods heroes, resulting in two terms, gods and heroes, which are used as individual terms in their own term queries. The two term queries are then combined using a bool query, which is a compound query. We will also look at different compound queries in the next section.

We will cover the following full-text queries in the following sections:

  • Match query
  • Match phrase query
  • Multi match query
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset