UI Search addFilter issue works only once

I am using two Elasticsearch engines and drivers to build a search functionality on vue. The first driver is used to search across all the profiles that I indexed in an engine called profiles. The other driver is used to search across another engine called products. After I get the response from my first engine and get n objects, I am trying to query the other engine with the user id and another filter n times. The problem is that when I try to add filters to the products driver, it seems to only add the first filter that I give it. It ignores every other filter. And when I call the setSearchTerm function, it removes that filter even when I use shouldClearFilters: false, or when I put the filter after the search query (maybe in this case it does not even add the filter at all?).

The first driver's code is almost completely identical to yakhinvadim's vue
app search demo. Which can be found here. (Commits · elastic/vue-search-ui-demo · GitHub).

Attached is the relevant code for the second driver

{
data() {
  return {
      searchState: {},
      products: [],
      sortBy: "relevance",
    };
},
watch: {
 sortBy(newSortBy) {
  driver.setSort(newSortBy, "asc");
    },
 searchInputValue() {
     this.getProducts();
     },
 },

 methods: {
  async getProducts() {
  

  const valueforApi = this.result.id.raw;
  
  await driver.addFilter("availability", "available", "all");

  await driver.addFilter("user_id", valueforApi , "all");
  //driver.setSearchTerm(this.searchInputValue,  {shouldClearFilters: false})

  //await driver.addFilter("availability", "available", "all");
  //await driver.addFilter("user_id", valueforApi , "all");

},
},
mounted() {
    driver.subscribeToStateChanges(  (state) => {
       this.searchState =  state;
   });

    if (this.searchInputValue.length > 1) {
      this.getProducts();
        }
  },
};

Jeez turns out I was using a very outdated version. Update your packages folks

2 Likes

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