Skip to content

search:and-not-query is ignored in QueryBatcher #1640

Closed
@marcopacurariu3

Description

@marcopacurariu3

Version of MarkLogic Java Client API

6.5.0

Version of MarkLogic Server

11.0.2

Java version

JDK 17

OS and version

ProductName: macOS
ProductVersion: 13.5
BuildVersion: 22G74

Input: Some code to illustrate the problem

final RawCombinedQueryDefinition structQueryDef = queryManager
            .newRawCombinedQueryDefinition(new StringHandle(
                """
                    <search:search xmlns:search="http://marklogic.com/appservices/search">
                       <search:query>
                          <query xmlns="http://marklogic.com/appservices/search" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                             <search:and-query>
                                   <search:range-constraint-query>
                                      <search:constraint-name>application</search:constraint-name>
                                      <search:value>testapp</search:value>
                                      <search:range-operator>EQ</search:range-operator>
                                   </search:range-constraint-query>
                                   <search:and-not-query>
                                      <search:annotation type="searchable-collections" />
                                      <search:positive>
                                         <search:collection-query>
                                            <search:uri>workspace/testapp/someCollection</search:uri>
                                         </search:collection-query>
                                      </search:positive>
                                      <search:negative>
                                            <search:collection-query>
                                               <search:uri>workspace/testapp/ignoredCollection</search:uri>
                                            </search:collection-query>
                                      </search:negative>
                                   </search:and-not-query>
                             </search:and-query>
                          </query>
                       </search:query>
                    </search:search>
                    """), "all");

While executing a query that contains a search:and-not-query, I noticed that the QueryBatcher is simply ignoring that part. However, the same query that is executed for a simple search does work.

final SearchHandle result = queryManager.search(structQueryDef, new SearchHandle()); result.getMatchResults();

The above search works. Same query passed to a QueryBatcher and calling batcher.getItems() does not take into account the and-not-query part.

Actual output: What did you observe? What errors did you see? Can you attach the logs? (Java logs, MarkLogic logs)

Executing the above query does not take into account the and-not-query for QueryBatcher.

Expected output: What specifically did you expect to happen?

The and-not-query is taken into account for QueryBatcher.

Alternatives: What else have you tried, actual/expected?

I have found a possible solution, instead of using directly the and-not-query, I have combined a manual and with a not, and it works like this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions