I have the following XML. When I search for city as Bangalore & state as Telegana it should not return any result since the city and state belong to different address elements...
XML Document  :
<person>
    <name>Sundeep</name>
    <address>
        <city>Bangalore</city>
        <state>Karnataka</state>
    </address>
    <address>
        <city>Hyderabad</city>
        <state>Telangana</state>
    </address>
</person>
Search for: city=Bangalore & state=Telangana
Current Output : It returns the person document when using below query
<search:and-query>
    <search:value-query>
        <search:element name="city"/>
        <search:text>Bangalore</search:text>
    </search:value-query>
    <search:value-query>
        <search:element name="state"/>
        <search:text>Telangana</search:text>            
    </search:value-query>
</search:and-query>
Excepted Output: Since both city and state belong to two different address element it should not return the above document in the result. Any pointers in solving this issue using REST-API or XQuery ?
                        
I actually just solved this problem earlier today using the /v1/search REST API here: Marklogic 8 xml search
To use xQuery for a solution this will work just fine for you: