Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsed Lucene query provider #11560

Closed
Piedone opened this issue Apr 19, 2022 · 6 comments · Fixed by #11561
Closed

Parsed Lucene query provider #11560

Piedone opened this issue Apr 19, 2022 · 6 comments · Fixed by #11561
Assignees
Milestone

Comments

@Piedone
Copy link
Member

Piedone commented Apr 19, 2022

Is your feature request related to a problem? Please describe.

You can write elaborate Lucene Queries with the ElasticSearch DSL. This includes the match query type (akin to using the my search term syntax in the search box) and match_all (like writing "my search term" for exact search). And you can optionally use the parsed Lucene search syntax in the search text box. However, you can't combine the two, you can't add the ability to use the search syntax with a Query.

Describe the solution you'd like

Add an ILuceneQueryProvider to address this.

Describe alternatives you've considered

You can use simple search but then you loose out on Queries.

@Skrypt
Copy link
Contributor

Skrypt commented Apr 19, 2022

Have you tried using a Boolean query like a "must" == "AND" or "should" == "OR"?

Or maybe I don't understand the request exactly. Because you can use a match and a match_all in the same Query by using the Boolean Query. Else, if it's about the search syntax from the search form then maybe you are right; I don't remember exactly.

@Skrypt
Copy link
Contributor

Skrypt commented Apr 19, 2022

The match query also has an "operator" param which can be set to "AND" or "OR" (Default).

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html#query-dsl-match-query-boolean

@Piedone
Copy link
Member Author

Piedone commented Apr 19, 2022

I included "Lucene" in the title so you'd jump on it right away :D.

Yes, I tried those. I didn't clarify it, but this is not about coding the query by hand but allowing the usage of the Query Parser Syntax so it can also come from a parameter. So, e.g. you can combine a search field with a more elaborate query to offer complex search.

I'll open a PR in a minute and you'll see :).

@sebastienros
Copy link
Member

@Skrypt mentions this one https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html that we already implement

and there is also this one that might be interesting, as it uses a simpler syntax
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html but we don't support it (yet?)

@sebastienros
Copy link
Member

Question is what's the difference between QueryParser and MultiField query parser.

@sebastienros sebastienros added this to the 1.x milestone Apr 21, 2022
@Piedone
Copy link
Member Author

Piedone commented Apr 21, 2022

Indeed, I've missed that (it's not in the docs, will add it) but it doesn't seem to work as I expect. E.g. this matches an item with the exact "exploration" word in its Content.ContentItem.FullText field.

{
  "query":
  {
    "parsed": {
      "Content.ContentItem.FullText": {
        "query": "\"exploration\""
      }
    }
  }
}

This, however, doesn't match anything in the same index:

{
  "query":
  {
    "query_string": {
      "query": "\"exploration\"",
      "default_field": "Content.ContentItem.FullText"
    }
  }
}

This works though:

{
  "query":
  {
    "query_string": {
      "query": "Content.ContentItem.FullText:\"exploration\""
    }
  }
}

I fixed this in the linked PR. simple_query_string is also available but also missing from the docs, added it too.

It seems to me that the only difference notable here between MultiFieldQueryParser and QueryParser is that the former can query multiple fields at once with the field names supplied in its ctor. But that shouldn't be an issue because supposedly QueryParser supports that as too, as part of the query syntax.

@sebastienros sebastienros modified the milestones: 1.x, 1.4 Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants