Xdcr - how to filter by list of id

For filtering by id=1
this is working:
'REGEXP_CONTAINS(META().id , “1”)

I need to implement filtering by thousands of specific ids.
something like:
'REGEXP_CONTAINS(META().id , [“1”,“222”,“444” …])

Another example of use ,
lets say i want to filter by specific field AND by list of possible Customer_IDs
tried:

REGEXP_CONTAINS(xattrs.CONV_RUN_NO,"Y") AND Customer_ID in [1,2,3]

This even dont pass the api validaiton(error 400)

Any idea?

@BgOKcomp , try : REGEXP_CONTAINS(META().id , “1 | 222 | 444”)
and
REGEXP_CONTAINS(xattrs.CONV_RUN_NO,“Y”) AND REGEXP_CONTAINS(Customer_ID ,“1|2|3”)

@pavithra.mahamani , thanks !
Using “|” as OR working :slight_smile:

Strange behavior in the xdcr for string type .
below n1sql working perfectly:
SELECT raw meta().id from party.organizationsearch WHERE REGEXP_CONTAINS(meta().id,“Organization_101394248184481173|Organization_325048616475917994”)

Or even this acceptable when running as query:
REGEXP_CONTAINS(TOSTRING(meta().id),“Organization248184481173|Organization_325048616475917994”)

When i implement same on xdcr :
image

It seems that when comparing REGEXP_CONTAINS(key ,val)
the xdcr see un quoted key as integer ,or quoted key as string .
so it expect the value return as integer for un quoted key.
I tried to wrap the meta.id with TOSTRING() .
REGEXP_CONTAINS(TOSTRING(meta().id),“Organization_101394248184481173|Organization_325048616475917994”)
it not accepted .

It looks like bug or least (annoying ) limitation ,
as if from one hand xdcr interpret un quoted key as int from the other hand it wont let using any TO<STRING/NUMBER> .

Q:
1.Do u see any workaround for using meta().id "?
2.Case no WA , do u see anyother approach which will be easily implement to uniquely identify a document ?

@BgOKcomp , “|” only works with int or float types. This works for me:
REGEXP_CONTAINS(META().id, “^Organization_(?=101394248184481173|325048616475917994)”)

Also note that META().id is case sensitive.
https://docs.couchbase.com/server/current/xdcr-reference/xdcr-filtering-expressions.html

Thanks @pavithra.mahamani

it assume that all id start with “Organization”,
But i need to provide a predefine list of specific ids to xdcr.
i.e Organization_1, Indv_2, anything_4, 5,6

Is there such option ?

Strangely when running it as statement similar to " IN " clause ,
it does working:
SELECT raw meta().id from party.organizationsearch WHERE REGEXP_CONTAINS(meta().id,“Organization_101394248184481173|Organization_325048616475917994”)
but not in xdcr .

second Q please,
Is there a way for using xdcr filtering by the return of id if other statement
i.e
select META().id from my_bucket_xdcr_id

Do you mind sharing why you need to filter by specific ids? If the doc ids do not follow a pattern, I would suggest adding a key to the docs that you are interested in filtering and then just checking the existence of that key → EXISTS(key).

I need to move quite large of selective data ,
the selection which document is relevant for the copy is define by predefine meta.(id) list,
or can the list in some temporary bucket ,
i have about ~10 buckers where the relation between them is not direct and some cases
the logic can be quite complex due to complex relation with nested json.

so i prepare pre process which preparing a list of id for each bucket ,
next , im working on xdcr program that will go over each bucket and include only relevant ids.
then , the program check for if such id exist in target system , and decide by predefine rules whether to copy or not .
So the question remain,
How can i run xdcr by list of predefine meta().id ,
either provide by a hardcode list or a " select meta().id …" from bucket.

@BgOKcomp , using query you can insert a temporary key into the list of docs you want to move. Then use EXISTS(key) to filter the replication.

can i get some examples for REGEXP_LIKE() also ?