barseghyanartur / graphene-elastic

Graphene Elasticsearch/OpenSearch (DSL) integration
https://pypi.org/project/graphene-elastic/
71 stars 17 forks source link

Fiter several fields using OR #47

Closed dmalisani closed 3 years ago

dmalisani commented 3 years ago

I need to find records which fields description OR searchKeys contain SEARCHED_STRING

{
  productsSearching(
    filter: {
        description:{wildcard:"*SEARCHED_STRING*"},
        searchKeys:{wildcard:"*SEARCHED_STRING*"}

    }

  ) {
    edges {
      node {
        id,
        description,
        ownCode,
        searchKeys
      }
    }
  }
}

but I only achieve AND results

barseghyanartur commented 3 years ago

Good question. Easiest way to achieve this now is to use query string or simple query string backends.

dmalisani commented 3 years ago

Yes, but I cannot use wildcard on these ways right?

barseghyanartur commented 3 years ago

@dmalisani:

Yes, you can.

    query PostsQuery {
      allPostDocuments(
        queryString:"(title:*oint) OR (content:Whit*)"
      ) {
        edges {
          node {
            id
            title
            category
            content
            createdAt
            comments
          }
        }
      }
    }

Where title and content are fields here. The * stands for wildcard. Read the official documentation (wildcard section).