Can you add additional fields to _geoloc to make it filterable?

I am aware that you can turn _geoloc into an array of GPS coordinates but is it going to cause any issues to add additional fields to those objects? The positions that I am storing are different for different days of the week and I want to be able to do a nearby search but only for the geolocation stored for a specific day of the week.

The basic form of a geoloc object is just { lat: “47.7”, lng: “-122.3” } but would Algolia freak out if I stored it as { lat: “47.7”, lng: “-122.3”, day: “Sunday” } ? And if I did that could I filter based on that?

Hi @projectfoodtrucker,

Thanks for contacting Algolia. From your description, it sounds like you want to be able to search for a food truck based on location and day of the week (at its simplest). Is that correct?

I would recommend having one food truck object per day. For example:

{
    "name": "Super Burrito Truck",
    "day": "Monday",
    "_geoloc": { lat: “47.7”, lng: “-122.3” }
}
.... // other days
{
    "name": "Super Burrito Truck",
    "day": "Sunday",
    "_geoloc": { lat: “47.7”, lng: “-122.3” }
}

This way you can set “day” as a facet for filtering.

Thanks for the response Ajay. Yeah that’s pretty much exactly it. If I want to use the same Object Id for all of the objects would it make sense to split the days up into separate indices? Is there any drawback to that?

Hi @projectfoodtrucker, each record in an index must have unique objectIDs, so you will have to put them in separate indices if you want them to have the same objectID. Is there a reason you couldn’t have a separate attribute that was an ID to indicate the same truck? (I’m assuming that’s why you want them to have the same objectID). You could have just an ‘id’ attribute and filter by that attribute if you wanted to find all the records for the same truck. Or you could even use the ‘name’ attribute which should be the same on all of the records for the same truck. Let me know if I’ve misunderstood what you are trying to do.

@cindy.cullen I could definitely put it in a separate ID field within those objects. Within the .NET SDK what’s the best way to delete objects based on an attribute? DeleteBy?

Hi @projectfoodtrucker, Yes, but be aware: This method should only be used if you cannot get the list of objectIDs you want to delete; These operations cannot be processed in parallel by the engine . If possible, use the delete method instead which is significantly more performant.

The deleteBy can be an expensive operation and should be used infrequently.