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

Query tags field with a match query (use mapping analyzer) #2690

Merged
merged 1 commit into from Oct 29, 2015

Conversation

Projects
None yet
2 participants
@nickstenning
Contributor

nickstenning commented Oct 29, 2015

The "tags" field is stored in Elasticsearch analysed (by our custom "uni_normalizer" analyzer). This means, broadly, that in the inverted index, individual terms in a tag will be stripped of punctuation and case-normalised. As such, we need to do the same normalisation when querying, and the easiest way to do this is with a match query.

This commit changes "tag" queries so that:

  • all tag parameters must match
  • multiple tokens within one tag query are all required to match

By way of example, for an annotation with tags:

["hello", "#THERE", "big world"]

These queries will match:

tag=hello
tag=HELLO
tag=#hello
tag=hello&tag=there
tag=hello&tag=there&tag=big+world
tag=hello&tag=there&tag=world+big

Whereas these will not:

tag=he+llo
tag=hello&tag=monkeys
tag=hello&tag=world

Fixes #2655.

Query tags field with a match query (use mapping analyzer)
The "tags" field is stored in Elasticsearch analysed (by our custom
"uni_normalizer" analyzer). This means, broadly, that in the inverted
index, individual terms in a tag will be stripped of punctuation and
case-normalised.  As such, we need to do the same normalisation when
querying, and the easiest way to do this is with a match query.

This commit changes "tag" queries so that:

- all tag parameters must match
- multiple tokens within one tag query are all required to match

By way of example, for an annotation with tags:

    ["hello", "#THERE", "big world"]

These queries will match:

    tag=hello
    tag=HELLO
    tag=#hello
    tag=hello&tag=there
    tag=hello&tag=there&tag=big+world
    tag=hello&tag=there&tag=world+big

Whereas these will not:

    tag=he+llo
    tag=hello&tag=monkeys
    tag=hello&tag=world

Fixes #2655.
@seanh

This comment has been minimized.

Show comment
Hide comment
@seanh

seanh Oct 29, 2015

Contributor

Lgtm, just waiting for Travis

Contributor

seanh commented Oct 29, 2015

Lgtm, just waiting for Travis

seanh added a commit that referenced this pull request Oct 29, 2015

Merge pull request #2690 from hypothesis/match-tags-according-to-mapp…
…ing-analyzer

Query tags field with a match query (use mapping analyzer)

@seanh seanh merged commit cd3fd6b into master Oct 29, 2015

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@seanh seanh deleted the match-tags-according-to-mapping-analyzer branch Oct 29, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment