# Free text search with App Search/Elastic Search UI with string , AND/ OR options?

**URL:** https://discuss.elastic.co/t/free-text-search-with-app-search-elastic-search-ui-with-string-and-or-options/343026
**Category:** Elastic Search
**Tags:** elastic-app-search
**Created:** [September 14, 2023, 8:17am UTC](https://discuss.elastic.co/t/free-text-search-with-app-search-elastic-search-ui-with-string-and-or-options/343026 "2023-09-14T08:17:09Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![thomas-ld](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@thomas-ld](https://discuss.elastic.co/u/thomas-ld)
#### Post date: [September 14, 2023, 8:17am UTC](https://discuss.elastic.co/t/free-text-search-with-app-search-elastic-search-ui-with-string-and-or-options/343026/1 "2023-09-14T08:17:09Z")

</div>

Does Elastic AppSearch/UISearch support implementing free text search on large text fields ?

I would like to use ElasticSearchUI / SearchBox with option to search like:

"whale was seen in" + houston - dalas

I.e. use " " for exact match of string and +/- (or AND/OR) to include exclude other terms.

Is that possible by using Elastic AppSearch/UI search ? I'm using the react example app generated from Elasticsearch as base for my application, behavior of the provided SearchBox seems to be single word terms with OR as default between. I haven't found any config parameters to change that behavior, is it even possible?

Any tips/ideas are appreciated!

---

<div class="post-metadata">

### Author: ![thomas-ld](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@thomas-ld](https://discuss.elastic.co/u/thomas-ld)
#### Post date: [September 14, 2023, 9:32am UTC](https://discuss.elastic.co/t/free-text-search-with-app-search-elastic-search-ui-with-string-and-or-options/343026/2 "2023-09-14T09:32:53Z")

</div>

Ok, I now see in the browser debugger that the query string looks like this when passed on to elastic app search: ""whale was seen in" + houston - dalas"

Is it perhaps just a matter of enabling Lucene Query Syntax in the App Search engine? (Or when creating the index ?) How to do that ?

---

<div class="post-metadata">

### Author: ![Carlos\_D](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_d/32/126245_2.png) [@Carlos\_D](https://discuss.elastic.co/u/Carlos_D)
#### Post date: [September 14, 2023, 12:24pm UTC](https://discuss.elastic.co/t/free-text-search-with-app-search-elastic-search-ui-with-string-and-or-options/343026/3 "2023-09-14T12:24:12Z")

</div>

Hi @thomas-ld !

Lucene query syntax is supported (see [docs](https://www.elastic.co/guide/en/app-search/current/search.html#search-api-request-body)).

The following test works on the test engine (national-parks-demo) using Search UI: `"situated on" -olympic +yellowstone`

The default behaviour when not using Lucene syntax is to try finding as many terms as possible, depending on the relevance of the terms. If you need to find specific terms, I'd suggest you use the Lucene syntax.

Is there anything else we can help you with?

---

<div class="post-metadata">

### Author: ![Kathleen\_DeRusso](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kathleen_derusso/32/132039_2.png) [@Kathleen\_DeRusso](https://discuss.elastic.co/u/Kathleen_DeRusso)
#### Post date: [September 14, 2023, 12:24pm UTC](https://discuss.elastic.co/t/free-text-search-with-app-search-elastic-search-ui-with-string-and-or-options/343026/4 "2023-09-14T12:24:23Z")

</div>

Hi @thomas-ld ,

Unfortunately there is a [known issue with App search that Lucene boolean search syntax can return unexpected results](https://www.elastic.co/guide/en/app-search/current/known-issues.html).

Our recommended workaround here is to use the [Elasticsearch Search API for App Search](https://www.elastic.co/guide/en/app-search/current/elasticsearch-search-api-reference.html), which will allow you to send Elasticsearch requests (such as [Boolean queries](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)) to your App Search indices.

This will send in an Elasticsearch request that overrides app search’s configuration.If you use the [explain](https://www.elastic.co/guide/en/app-search/current/search-explain.html) API, though, you can see the queries that are being passed in and you can adjust them. The issue with lucene syntax today involves the `minimum_should_match` value, which often conflicts with Lucene’s boolean syntax logic.If you’re doing an `AND` search with a `minimum_should_match` of 1, it effectively becomes an OR query (only one needs to match).So it’s a bit of a workaround, but using explain to get the query you want and transforming it to Elasticsearch query DSL is the best way to have complete control over your result set.

---

<div class="post-metadata">

### Author: ![thomas-ld](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@thomas-ld](https://discuss.elastic.co/u/thomas-ld)
#### Post date: [September 14, 2023, 1:29pm UTC](https://discuss.elastic.co/t/free-text-search-with-app-search-elastic-search-ui-with-string-and-or-options/343026/5 "2023-09-14T13:29:19Z")

</div>

Ok, thank for the feedback!  
I think my problem is my index, I have created the index with elastic directly and not via app search.  
When looking at the index in app search i see that message: "Missing subfields" for my text fields I'm searching in. Reading the docs I see that there are some subfields required for appsearch to work properly.  
Ref:

> **[Elasticsearch engines text field conventions | App Search documentation \[8.10\]...](https://www.elastic.co/guide/en/app-search/current/elasticsearch-engines-text-subfields-support-conventions.html)**

I then tried to create a new index with a field "text" with subfields to try to mimic what is said in the link above (see mapping below). But still get same warning. Do you know how to create the subfields to get a field properly working with app search ? Should type be something else than text for the different sub fields ?

This is how I created the index:

```auto
{
  "settings": {
    "number_of_shards": 1
  },
  "mappings": {
    "properties": {
      "Date": {
        "type": "date"
      },
      "text": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          },
          "category": {
            "type": "text"
          },
          "prefix": {
            "type": "text"
          }, 
          "delimiter": {
            "type": "text"
          },
          "joined": {
            "type": "text"
          },
          "stem":{
            "type": "text"
          }
        }
      }	
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![Kathleen\_DeRusso](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kathleen_derusso/32/132039_2.png) [@Kathleen\_DeRusso](https://discuss.elastic.co/u/Kathleen_DeRusso)
#### Post date: [September 14, 2023, 2:11pm UTC](https://discuss.elastic.co/t/free-text-search-with-app-search-elastic-search-ui-with-string-and-or-options/343026/6 "2023-09-14T14:11:20Z")

</div>

`text` should be fine, you can find out more information on how to customize these mappings in our [text field support conventions](https://www.elastic.co/guide/en/app-search/current/elasticsearch-engines-text-subfields-support-conventions.html) documentation.

Here is an example of the default mappings that App search creates when an index is created:

```auto
{
  ".ent-search-engine-documents-test": {
    "mappings": {
      "dynamic": "true",
      "dynamic_templates": [
        {
          "permissions": {
            "match": "_*_permissions",
            "mapping": {
              "type": "keyword"
            }
          }
        },
        {
          "thumbnails": {
            "match": "_thumbnail_*",
            "mapping": {
              "type": "binary"
            }
          }
        },
        {
          "data": {
            "match_mapping_type": "*",
            "mapping": {
              "analyzer": "iq_text_base",
              "fields": {
                "date": {
                  "format": "strict_date_time||strict_date",
                  "ignore_malformed": true,
                  "type": "date"
                },
                "prefix": {
                  "search_analyzer": "q_prefix",
                  "analyzer": "i_prefix",
                  "type": "text",
                  "index_options": "docs"
                },
                "delimiter": {
                  "analyzer": "iq_text_delimiter",
                  "type": "text",
                  "index_options": "freqs"
                },
                "joined": {
                  "search_analyzer": "q_text_bigram",
                  "analyzer": "i_text_bigram",
                  "type": "text",
                  "index_options": "freqs"
                },
                "location": {
                  "ignore_malformed": true,
                  "type": "geo_point",
                  "ignore_z_value": false
                },
                "float": {
                  "ignore_malformed": true,
                  "type": "double"
                },
                "enum": {
                  "ignore_above": 2048,
                  "type": "keyword"
                },
                "stem": {
                  "analyzer": "iq_text_stem",
                  "type": "text"
                }
              },
              "index_options": "freqs",
              "type": "text"
            }
          }
        }
      ],
      "properties": {
        "id": {
          "type": "keyword"
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![thomas-ld](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@thomas-ld](https://discuss.elastic.co/u/thomas-ld)
#### Post date: [September 14, 2023, 3:09pm UTC](https://discuss.elastic.co/t/free-text-search-with-app-search-elastic-search-ui-with-string-and-or-options/343026/7 "2023-09-14T15:09:55Z")

</div>

> [@Kathleen\_DeRusso](#):
>
> `analyzer`

Now created a new index with following subfields added to the text fields and then string and exclusive search works as expected! Thanks for the support!

```auto
		"prefix": {
		  "type": "text",
		  "index_options": "docs"
		},
		"delimiter": {
		  "type": "text",
		  "index_options": "freqs"
		},
		"joined": {
		  "type": "text",
		  "index_options": "freqs"
		},             
		"stem": {
		  "type": "text"
		}

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [October 12, 2023, 3:10pm UTC](https://discuss.elastic.co/t/free-text-search-with-app-search-elastic-search-ui-with-string-and-or-options/343026/8 "2023-10-12T15:10:33Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
