Search code examples
reactjselasticsearchreactivesearch

Suggestions are not showing for DataSearch when the search needs to happen on elastic field of array type


My elastic search provides the results as an elastic array. Here is how the mappings look.

 "positions": {
            "properties": {
              "en": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "fr": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }

So this gives me result as below.

"companyinfo.positions.en": " Chain Corporate, Food Services, Service Manager, Restaurant Manager, Cybercafé Manager, Internet Café Manager, Assistant Bar Manager, Assistant Manager, Restaurant Assistant Manager, Banquet Manager, Bar Manager, Cafeteria Manager",

I am using value as "companyinfo.positions.en" for the dataField property of the DataSearch control.

Currently I am not using the onSuggestion property, rather I am expecting DataSearch to provide me the suggestions automatically. But it is not giving me any suggestions. But the control gives me the search results as expected.

<DataSearch 
    componentId={id}
    dataField={'companyinfo.positions.en'}        
    placeholder={'Search Jobs'}                
    URLParams={true}
    autosuggest={true}        
    showClear={true}                
    />      

If I provide any other textfield as a dataField for the DataSearch control, then I get the suggestions, why not it works for the elastic array fields.

Please suggest what I can do to get the suggestions correctly. If I will have to use the onSuggestion property, how do I provide the field name as for the label, I can't provide the field name.


Solution

  • This was an issue with nested array fields in the library and was fixed in v2.8.2. Changelog