# Elastic Search UI - Adding filter returns all results

**URL:** https://discuss.elastic.co/t/elastic-search-ui-adding-filter-returns-all-results/354095
**Category:** Elasticsearch
**Created:** [February 26, 2024, 8:11am UTC](https://discuss.elastic.co/t/elastic-search-ui-adding-filter-returns-all-results/354095 "2024-02-26T08:11:21Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jackfrost](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@jackfrost](https://discuss.elastic.co/u/jackfrost)
#### Post date: [February 26, 2024, 8:11am UTC](https://discuss.elastic.co/t/elastic-search-ui-adding-filter-returns-all-results/354095/1 "2024-02-26T08:11:21Z")

</div>

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

```auto
{
  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

```auto
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.

---

<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: [March 25, 2024, 8:11am UTC](https://discuss.elastic.co/t/elastic-search-ui-adding-filter-returns-all-results/354095/2 "2024-03-25T08:11:39Z")

</div>

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