Filtering sting attribute

I have string attributes that have been added to searchableAttributes.

In the Algolia console I am trying to create a filter

{"filters":"title:Calvin"}
{"filters":"title:'Calvin Klein CK IN2U Him 150ml edt'"}

Neither of there are getting hits - the second one is a cut-n-paste of actual title.

What is the syntax for filtering strings?


What I really want to be able to do is create a filter for blank title (empty string)

Made some progress, needed to add attribute to attributesForFaceting

still need to work out how to filter for empty string

Hi @ajmercer, Filtering for an empty string is not possible, however what you can do instead is either add an extra attribute, like hasTitle that you can set to be false if the title is an empty string, e.g.

{
    "title":"Calvin",
    "hasTitle":true,
},
{
    "title":"",
    "hasTitle":false,
}

or alternatively you could add a tag:

{
    "title":"Calvin",
    "_tags": [],
},
{
    "title":"",
    "_tags": ["isTitleEmpty"],
}

and then use that to filter: https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/how-to/filter-by-tags/

1 Like

the field I wanted to check only has two values, so I was able to do this

{"filters":"(NOT productstockstatus:'In Stock') AND (NOT productstockstatus:'Temporary Out of Stock')"}
1 Like