How can I search by something similar to array.Notincludes? for one of the attributes?

Basically, I have a basic object with the following attributes interested

{
“name”: “First Last”,
“description”: “Description”,
“is_published”: true,
“interested_in”: [1,2,3,4,5]
}
And, I want to do the following query:

name=First
AND
is_publshed is true
AND
interested_in not includes 3

Is this possible?

Something like this perhaps

index.search('query', {
  filters: '(name:John OR is_published:true) AND NOT interested_in:sports'
});

which comes from Filters and Boolean Operators docs. Also check out filters which has a handy syntax validator at the bottom of the page.

Thanks for your reply.
It was very helpful for me.
I have one more question.
How can I search with multiple values?
For example:
{
“id”: “id1”,
“name”: “First Last”,
“description”: “Description”,
}

blckedIds = [id1, id2, id3]

I want to do the following query:

name=First
AND
id not in array blockedIds

I will appreciate if this is possible or not in algolia.
Thanks

This is a valid filter syntax, but if you had 100 values in blockedids you would end up with a very long query string:

index.search('query', {
  filters: '(name:Joe AND lives:Mars) AND (NOT id:id1 AND NOT id:id2 AND NOT id:id3)'
});

Better option perhaps is to have a key/value pair of is_blocked: true in your data and filter/facet against that value for example

index.search('query', {
  filters: '(name:Joe AND lives:Mars) AND blocked:false'
});

Thank you very much.
This was very, very helpful.
I recommend you.
Would you please share your contact so that we can have a live chat?
I have some question about algolia query.
I really appreciate if you let me know your contact or contact me.
Please contact me via skype.
You can search me in skype: danulo.zgezdilov.dev@gmail.com
Looking forward to hearing from you soon.
Thanks again.

Is there any way to use attribute value?
For example:
{
“id”: “id1”,
“name” : “First”,
“description”: “first description”
}

I want to use “name” attribute value when searching like the following query.
description=(“name” attribute value = “First”)

So the query would be:
description = “First”
because I am using “name” attribue.

Is this possible?

I’m not sure I quite understand what you are attempting to do. Do you want to filter based on what is in the description field when name matches your filter?

Thanks for your reply.
Yes, correct.
I want to use name field as the filter when filtering.
Is this possible?

If you search for First it will find results on any attribute that you have configured as a searchable attribute then use filters to find instances of name matches. For instance

let query = "First"
index.search(query, {
  searchableAttributes: [
    'description',
  ],
  filters: `name:${query}`
});

I think this is what you are trying to do.

Sorry, this is what I am trying to do.
I want to get results where “description” = = “First”.
I want to get results where description is same as its “name” value.
Here “First” is “name” value.
So the query would be :
“description” == “${name}”
Do you understand what I mean?

If you were to run this exact query, that would mean description == name which would mean description and name would have exactly the same values e.g.

[{
  "name": "John",
  "description": "John",
}]

which would mean performing

index.search('John');

would return that record.

In what context are you trying to perform these requests? What is the use case? Have you read the docs Sort By Attribute and those to do with Filtering?

Yes, that is just an example.
I need this for setAroundLatLng.
The data is following:
{
producName: “AA”
prod_location: [48.3830, 31.1829],
distance: 1000
}

When the user signs up, each user also has their location.
The product data means that the product is shown by the user who is away 1000m from the prod_location.
So I need to query like this.
index.setAroundLatLng(${prod_location.latitude}, ${prod_location.longitude})
.setAroundRadius(1000)

I think that you understand what I mean.
Please check and let me know if this is possible

As shown in the Filter Results Around a Location you need to specify _geoloc in your dataset (the example given)

[
 {
    "objectID": "3797",
    "name": "John F Kennedy Intl",
    "city": "New York",
    "country": "United States",
    "iata_code": "JFK",
    "_geoloc": {
      "lat": 40.639751,
      "lng": -73.778925
    },
    "links_count": 911
  }
]

Then you can search around that location (the example)

index.search('', {
  aroundLatLng: '40.71, -74.01',
  aroundRadius: 1000000 // 1000 km
}).then(({ hits }) => {
  console.log(hits);
});

Hi.
Thanks for your reply
Yes, I know how to filter by LatLng.
The problem is how to get the prod_location.
I need to use prod_location when filtering.
For example:
index.search(’’, {
aroundLatLng: ‘prod_location.lat, prod_location.lng’,
aroundRadius: 1000000 // 1000 km
}).then(({ hits }) => {
console.log(hits);
});
I need to use aroundLatLng value from the prod_location and aroundRadius from distance of product.
This means that the product is displayed only to users that is away 1000km from the product location.
Is this possible?