ceddy
1
I am currently running Geo spacial queries via rest API like this
{
from,
size,
query: {
location,
distance: `${distance}${unit}`,
field: "geo",
},
sort: [
{
by: "geo_distance",
field: "geo",
unit,
location,
},
]
}
i send this query using my index url via REST,
is there a way I can run the query using N1QL, the main reason is so that I can add other filters and selectors like WHERE, JOIN e.t.c
vsr1
2
https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/searchfun.html#search
SELECT RAW META(t1).id
FROM `travel-sample` AS t1
WHERE SEARCH(t1, { "from": 0, "size": 10, "query": { "location": { "lon": -2.235143, "lat": 53.482358 }, "distance": "100mi", "field": "geo" }, "sort": [ { "by": "geo_distance", "field": "geo", "unit": "mi", "location": { "lon": -2.235143, "lat": 53.482358 } } ] });
1 Like
ceddy
3
Thank you very much @vsr1, am always inspired when I see your answers,
I’d like a small favor, using the same example,
- can you add the index, let’s say my index is called
dev-index
,
- can you add another
WHERE
clause that selects like WHERE t1._type = "MyDocType"
Thank you very much @vsr1
vsr1
4
@ceddy , you can create type index and Add it as the AND clause. cc @abhinav has FTS expertise.
1 Like
ceddy
5
Yes got it, it’s very simple, thank you
{“index”: “travel”}