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

Email/query Allow filtering by Header #3737

Closed
remk opened this issue Sep 2, 2020 · 5 comments
Closed

Email/query Allow filtering by Header #3737

remk opened this issue Sep 2, 2020 · 5 comments
Assignees
Milestone

Comments

@remk
Copy link
Member

remk commented Sep 2, 2020

WHY

As a user i want to search for messages having a header field named after a certain value.
Also as a user i want to search for messages having a specific header field containing a given value.

header: String[] The array MUST contain either one or two elements. The first element is the name of the header field to match against. The second (optional) element is the text to look for in the header field value. If not supplied, the message matches simply if it has a header field of the given name.

To look for messages having a header field named 'myHeader' i can send this query.

[[ "Email/query",{
  "accountId": "ue150411c",
  "filter":  {
     "header":  ["myHeader"]
}
}, "0" ]]

To look for messages having a header field named 'myHeader' containing the word 'james' i can send this query.

[[ "Email/query",{
  "accountId": "ue150411c",
  "filter":  {
     "header":  ["myHeader", "james"]
}
}, "0" ]]

HOW

  • accept a 'header' field in the filter condition. Which should be a string array of length 1 or 2.
  • if the length is one, filter the results with emails containing a header field named after specified value
  • if the length is one, filter the results with emails containing a header field named after the first element of the array and containing the value specified in the second element of the array.
The exact semantics for matching String fields is deliberately not defined to allow for flexibility in indexing implementation, subject to the following:

    Any syntactically correct encoded sections [@!RFC2047] of header fields with a known encoding SHOULD be decoded before attempting to match text.

    Text SHOULD be matched in a case-insensitive manner.

    Text contained in either (but matched) single (‘) or double (“) quotes SHOULD be treated as a phrase search; that is, a match is required for that exact word or sequence of words, excluding the surrounding quotation marks.

DOD

  • write an integration test validating that we can filter mails by the fact they contains a specific header.
  • write an integration test validating that we can filter mails by the fact they contains a specific header with a value containing a given value
@chibenwa
Copy link
Member

chibenwa commented Sep 3, 2020

Text contained in either (but matched) single (‘) or double (“) quotes SHOULD be treated as a phrase search; that is, a match is required for that exact word or sequence of words, excluding the surrounding quotation marks.

I don't think we can easily handle that.

@chibenwa chibenwa added this to the Sprint 2 milestone Sep 3, 2020
@rouazana
Copy link

rouazana commented Sep 3, 2020

Text contained in either (but matched) single (‘) or double (“) quotes SHOULD be treated as a phrase search; that is, a match is required for that exact word or sequence of words, excluding the surrounding quotation marks.

I don't think we can easily handle that.

Why? It natively supported by ES query, no?

@chibenwa
Copy link
Member

chibenwa commented Sep 3, 2020

Why? It natively supported by ES query, no?

By design, ElasticSearch is badly suited for exact matching, so I'm skeptical.

Do you have a reference of a query doing so?

The "match" query documenbtation do not mention such a behaviour...

@chibenwa
Copy link
Member

chibenwa commented Sep 3, 2020

Cool but it is likely not the request we currently use nowaday at the search index level.

Maybe adapting that part would require more details in the ticket?

@chibenwa chibenwa self-assigned this Sep 28, 2020
@chibenwa chibenwa linked a pull request Sep 28, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants