search-ui icon indicating copy to clipboard operation
search-ui copied to clipboard

Elasticsearch 400 error when searching multiple words

Open cpebble opened this issue 1 year ago • 3 comments

Describe the bug We're trying to index and search through several internal knowledge bases. In context we have search-dropbox which uses the Elastic dropbox connector client(self-hosted) and search-sphinx which is indexed through a custom script.

Building the front-end with react and search-ui got us far <3 However, we have run into an issue when searching the Dropbox index. We can easily search for one word, however if we add a second word we get http 400. I.e. "Docker" works, but "Docker swarm" does not.

Specifically we get: search_phase_execution_exception which points to this error: failed to create query: field:[name] was indexed without position data; cannot run PhraseQuery.

And our QueryConfig is this:

{
  "searchQuery": {
    "search_fields": {
      "name": {
        "weight": 3
      },
      "body": {
        "weight": 5
      }
    },
    "result_fields": {
      "name": {
      },
      "body": {
        "snippet": { "size": 250, "fallback": true },
        "raw": {}
      },
      "file_path": {}
    },
  },
  "autocompleteQuery": {},
  "apiConnector": this.connector,
  "alwaysSearchOnInitialLoad": true
}

To Reproduce Steps to reproduce the behavior:

  1. Index a Dropbox target using Elastic Connector Clients
  2. Search this target

Expected behavior Search results

Which backends and packages are you using: Backend: Elasticsearch Packages: Search-ui, Search-ui-elastic-connector, react-search-ui

cpebble avatar May 30 '24 09:05 cpebble

Hey Thank you for your question, the issue is unlikely on the serch-ui side. Probably it's related to the field mapping, maybe using some no position data like "index_options": "docs" doc

yansavitski avatar Jun 12 '24 15:06 yansavitski

@yansavitski I did look at that, however the index(in Kibana) at least looks like this:

      "name": {
        "type": "text",
        "fields": {
        ....
        },
        "index_options": "freqs",
        "analyzer": "iq_text_base"
    }

Unless i'm completely off-base this should be right, right?

cpebble avatar Jun 14 '24 11:06 cpebble

Hey index_options: freqs Can't be use with match_phrase search with multiple words

You can play with index_options parameter by following the code bellow: `PUT /my_index_no_positions { "mappings": { "properties": { "content": { "type": "text", "index_options": "freqs" // No positions data } } } }

POST /my_index_no_positions/_doc/1 { "content": "This is a sample document to demonstrate match_phrase functionality." }

POST /my_index_no_positions/_doc/2 { "content": "Elasticsearch allows powerful full-text search capabilities." }

GET /my_index_no_positions/_search { "query": { "match_phrase": { "content": "full-text search" } } }`

yansavitski avatar Jun 17 '24 11:06 yansavitski

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Is this issue still important to you? If so, please leave a comment and let us know. As always, thank you for your contributions.

botelastic[bot] avatar Aug 16 '24 11:08 botelastic[bot]