Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

fix LDAP substring startswith filters #31

Merged
merged 1 commit into from
Jul 31, 2020

Conversation

butonic
Copy link
Member

@butonic butonic commented Jul 31, 2020

Filters like (mail=mar*) are currentld not parsed correctly, but they are used when searching for recipients. This PR correctly converts them to odata filters like startswith(mail,'mar').

ocis-accounts should already suppert phraseprefix bleve queries for odata startswith filters: https://github.com/owncloud/ocis-accounts/blob/master/pkg/provider/bleve.go#L29-L41

but I may not understand how to get phrase prefix queries working, yet ...

2020-07-31T17:39:27+02:00 DBG using query query={"conjuncts":[{"field":"bleve_type","term":"account"},{"disjuncts":[{"disjuncts":[{"field":"on_premises_sam_account_name","prefix":"'mar'"},{"field":"display_name","prefix":"'mar'"}],"min":0},{"field":"mail","prefix":"'mar'"}],"min":0}]} service=accounts
2020-07-31T17:39:27+02:00 DBG result result={"facets":null,"hits":[],"max_score":0,"request":{"explain":false,"facets":null,"fields":null,"from":0,"highlight":null,"includeLocations":false,"query":{"conjuncts":[{"field":"bleve_type","term":"account"},{"disjuncts":[{"disjuncts":[{"field":"on_premises_sam_account_name","prefix":"'mar'"},{"field":"display_name","prefix":"'mar'"}],"min":0},{"field":"mail","prefix":"'mar'"}],"min":0}]},"search_after":null,"search_before":null,"size":10,"sort":["-_score"]},"status":{"failed":0,"successful":1,"total":1},"took":38689,"total_hits":0} service=accounts

but on the cli it works:

../bleve/bleve query /var/tmp/ocis-accounts/index.bleve "mar" -t prefix -f on_premises_sam_account_name
1 matches, showing 1 through 1, took 546.089µs
    1. f7fbf8c8-139b-4376-b307-cf0a8c2d0d9c (3.351375)
        on_premises_sam_account_name
                marie

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
@butonic butonic requested a review from refs July 31, 2020 16:01
@refs refs merged commit ee3964a into owncloud:master Jul 31, 2020
@butonic butonic deleted the fix-startswith-queries branch July 31, 2020 20:26
@butonic butonic mentioned this pull request Jul 31, 2020
63 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants