Elastic Search UI - Adding filter returns all results

Hey All.

I am use Elasticsearch ui with the @elastic/search-ui-elasticsearch-connector. I currently have the search up and running. I am able to do a search for something like a name, and get one exact result back. All is good.

However I am now trying to update my search to apply filtering. However when I add the filtering I now get back my expected result AND every document that matches the filter.

Here is my setup.

I have my onSearch config

{
  search_fields: {
    name: {},
    siteName: {},
    role: {},
    organisation: {},
    email: {},
  },
  result_fields: {
    userId: { raw: {} },
    siteId: { raw: {} },
    requestId: { raw: {} },
    name: { snippet: {} },
    siteName: { snippet: {} },
    role: { snippet: {} },
    organisation: { snippet: {} },
    email: { snippet: {} },
    submittedOn: { raw: {} },
    status: { raw: {} },
  },

  facets: {
    'status.keyword': { type: 'value' },
  },
};


and at the moment I am using the withSearch HOC to get access to the addFilter function

const SetFilter = ({ addFilter, setFilter }: SearchPaginationProps): JSX.Element => {
  useEffect(() => {
    // setFilter('status', 'pending');
    addFilter('status', 'pending');
  }, []);
  return <></>;
};

const SearchSetFilter = withSearch(({ setFilter, addFilter }) => ({
  setFilter,
  addFilter,
}))(SetFilter);

What I am expecting is to get back a result that matches my search term AND matches the filter. So one record.

However what I am getting back is the item that matches my search term OR any item that matches the filter.

Am I missing something here?

Thanks.

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