REST API and Conditions


#1

Hi,
I’m using JSON/REST API request for FTS on our Couchbase /index/query. Everything is OK but I would like to query, for example:

(+A +B +C) OR (+A +B +D)

How can I create a query using JSON/REST API?

Thanks in advace.

Angelo


#2

Hey Angelo, this should do it:

curl -XPOST -H "Content-Type: application/json" http://<username>:<passwd>@<ip>:<port>/api/index/<indexName>/query -d
'{"query”:
	{"disjuncts”:
		[
			{“conjuncts”: [{"query": “A"}, {"query": “B”}, {"query": “C”}]},
			{“conjuncts”: [{"query": “A"}, {"query": “B”}, {"query": “D”}]},
		]
	}
}'

#3

Thank you so much for your suggestion!!!

Tomorrow, I’ll test it and I’ll report a feedback on this topic.

Angelo


#4

Hi abhinav,
Thanks a lot for your solution. It works!

Do you know when will be published officially, the release date for Couchbase 5.0?

Thanks.

Angelo


#5

@abhinav
hi
how we can search (ABC) ?

thanks


#6

@angelo.derrico.itcon Apologies for the late reply, couchbase 5.0’s release date is towards the end of this month.


#7

@ytuem96 if you mean A, B, C to be expressions, then your disjunction query would resemble:

curl -XPOST -H "Content-Type: application/json" http://<username>:<passwd>@<ip>:<port>/api/index/<indexName>/query -d
'{"query": {"disjuncts": [{"match": "A"}, {"match": "B"}, {"match": "C"}]}}'

#8

@abhinav
yea if it means and condition,ok