Ampersand gets stripped out of search query

I am having an issue where an ampersand is getting stripped out of the search query after the first run.

I had this issue in another spot where I was directly calling an endpoint and grabbing my searchterm from the params and fixed it by getting my search term from SearchContext

Now in another spot where the endpoint is hooked up in a connecter and I am grabbing the search query form the searchContext and in this one spot it doesn't work and strips out the ampersand. Everything sending in is correct.

Sending in hardcoded: "this & that"

const searchQuery = "this & that";

context.driver.setSearchQuery({ searchTerm: searchQuery });

Getting "this " returned:

import { SearchContext } from "@elastic/react-search-ui";

  const context = useContext(SearchContext);
  const searchTerm = context?.driver.state?.searchTerm;

  console.log("searchTerm:", searchTerm);

Is there an argument or a way I can get searchui to ignore the ampersand?

Hi @kudumine,

I think this topic might be relevant to you: Searching with special characters doesn't work

Hey there @kudumine, you should pass in a custom analyzer that doesn't filter out the special characters you want.

Thank you @kathleen for the response! Is there a way to set up a custom analyzer and pass it in on the front end? Or do you have any more examples of the implementation of that?

Thank you!

The docs I link show how to set up analyzers, they're part of your mappings and transparent to the frontend.

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