Last active
June 15, 2016 07:10
-
-
Save WietseWind/cd219b7d2c7d874cdfa26da2c8e734f3 to your computer and use it in GitHub Desktop.
nodum.io - Zoeken + Wildcard zoeken in nodum (Search)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Nodum CLI, version: {{ config.getVersion() }} | |
Ophalen uit Profit: | |
{% set raw_data = profit.get('I4U_Producten') %} | |
{{ raw_data|length }} resultaten. | |
{% set data = [] %} | |
{% for d in raw_data %} | |
{% set zoekinfo = (d.artcode ~ ' ' ~ d.artikel ~ ' ' ~ d.pdoms)|lower|preg_replace("@[^a-z0-9]@", " ")|preg_replace("@[ ]+@", " ")|trim %} | |
{% set data = data|merge([ d|a|merge({ zoekinfo : zoekinfo }) ]) %} | |
{% endfor %} | |
{% if data|length > 0 %} | |
Verwijderen in mongo: | |
{% do artikelen.delete({}) %} | |
Verwijderd. | |
Toevoegen aan mongo: | |
{% do artikelen.insertMany(data) %} | |
Toegevoegd. | |
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if param.post %} | |
{% set q = param.post.query|trim|lower|preg_replace("@[^a-z0-9]@", " ") %} | |
{% set r = artikelen.find( | |
{ '$text': { | |
'$search' : q, | |
'$caseSensitive' : false, | |
'$diacriticSensitive' : false | |
} }, | |
{ score: { '$meta': "textScore" } }, | |
{ score: { '$meta': "textScore" } })|assoc('_id') %} | |
{% set m = artikelen.find({ zoekinfo : { '$regex' : q|preg_replace("@[ ]+@", ".*"), '$options' : 'i' } })|assoc('_id') %} | |
{% set t = r|merge(m) %} | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment