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

Configurable strips #108

Merged
merged 4 commits into from
Oct 30, 2017
Merged

Configurable strips #108

merged 4 commits into from
Oct 30, 2017

Conversation

sveredyuk
Copy link
Collaborator

@sveredyuk sveredyuk commented Dec 20, 2016

Fixed #106

@sveredyuk
Copy link
Collaborator Author

Hi, @dblock any chance to fix CI ?

@dblock
Copy link
Contributor

dblock commented Dec 21, 2016

I'm really not actively involved in this project, I just brought it into the mongoid org. But if nobody steps up I could help out maybe. Would appreciate some PRs and happy to look and merge for trivial things like CI of course.

@sveredyuk
Copy link
Collaborator Author

@dblock Thx

@rtrv
Copy link
Collaborator

rtrv commented Oct 30, 2017

@sveredyuk check out Travis result. Your last commit "Sort filtered keys" damages functionality. And I suppose it's out of "configurable strips" feature scope. Without that change all tests are passing well

@sveredyuk
Copy link
Collaborator Author

sveredyuk commented Oct 30, 2017

@rtrv Hm... ok. I'll try to revert it. It was so time ago that I really don't remember why this code was changed but not committed.

This reverts commit e9d8b30.
@rtrv rtrv merged commit 7870f85 into mongoid:master Oct 30, 2017
@Mohakjuneja
Copy link

@sveredyuk I have an abbreviation field in my search criteria. However, an abbreviation such as B.E. is saved as two different keywords 'B' and 'E'. How can I ignore the dots while creating keywords for this field using configurable strips?

@sveredyuk
Copy link
Collaborator Author

@ Mohakjuneja You need one keyword like "BE" ?

@rtrv
Copy link
Collaborator

rtrv commented Oct 9, 2018

@Mohakjuneja here is the default configuration for gem initialization:

config.strip_symbols = /[._:;'\"`,?|+={}()!@#%^&*<>~\$\-\\\/\[\]]/

You can just remove the dot out of the regex:

config.strip_symbols = /[_:;'\"`,?|+={}()!@#%^&*<>~\$\-\\\/\[\]]/

Then you'll be able to search for "B.E." including dots and from the string Example string. the following keywords will be extracted: example and string. with a dot. If you want to search for BE, change config.strip_accents from the default:

config.strip_accents = /[^\s\p{Alnum}]/

To the following, adding the dot:

config.strip_accents = /[.^\s\p{Alnum}]/

Don't forget to reindex by

$ rake mongoid_search:index

@Mohakjuneja
Copy link

Thank you so much! That works!

@rgaufman
Copy link

rgaufman commented May 1, 2020

Any suggestion how to change the above to correctly index MAC addresses and IP addresses?

When I try the above,I get this :( <

test(staging)> Camera.active.map(&:_keywords)
=> [[], [], [], [], [], [], [], [], [":::::"], [], [":::::"], [":::::"], [":::::"]]

@rgaufman
Copy link

rgaufman commented May 1, 2020

Ah, this does what I want:

    config.strip_symbols = /[_;'\"`,?|+={}()!@#%^&*<>~\$\-\\\/\[\]]/
    config.strip_accents = /[^\s\p{Alnum}.:]/

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 this pull request may close these issues.

Config search to not ignore dots
5 participants