I'm trying to implement elasticsearch for searching products. Some product names contains numbers. I use fuzzy-search to make life easier for the users but I don't want the numbers to be fuzzy-searched. Can I disable fuzzy-search for numbers only but use it for the rest of the characters in a string?
Or is elasticsearch not fit for what I'm trying to achieve?
Example when searching for TV or monitors when I search for Manufacturer TV 55" I don't want Manufacturer TV 65" to show up in the results. Not in the top 10 at least.
You can check if search string is a number. In c#:
bool searchStringIsNumeric = int.TryParse(searchString, out int n);
In Elastic Search you could do something like this: (Using nest client here)
.Fuzziness(searchStringIsNumeric ? Fuzziness.EditDistance(0) : Fuzziness.AutoLength(4, 7))
Related
First off I'm a total novice for Javascript, so please go gently. I'm aware of how people feel about having to now pay for IFTTT, but it's perfect for what I need.
I am using a more expansive version of this code below to capture certain keywords from Tweets to then generate emails if the search returns a positive result. This search works very nicely, except it is case sensitive which is a problem.
Yes, I know you can manipulate the twitter search to pick up specific words or phrases. I am very proficient in achieving searches this way. I am casting a wide net to pick up approx 120 search words or phrases which is too long to achieve through "OR" Twitter search parameters alone which is why I'm using this.
Q1 - I have tried adding item.toLowerCase() and just .toLowerCase() in various parts of the code so it wouldn't matter if the sentence case of the search term is different to that of the original tweet text case. I just can't get it to work though. I've seen various posts on here but I can't get any of them to work in IFTTT. I believe IFTTT doesn't accept REGEX either, which is annoying.
Any advice of how to get this code running so it's case-insensitive for text within IFTTT?
Q2 - I have approx 120 search terms for the tweet text to return positive results. There is a lot of junk that comes through with that. Does anyone know how to add a second layer of 'and exclude' search terms?
I have something like 300-400 words and specific phrases which would be used to stop the email from being triggered - so it'd be something like "IF tweet text contains a, b, c BUT text ALSO contains x, y, z... do not send the email"
let str=Twitter.newTweetFromSearch.Text;
let searchTerms=[
"Northbound",
"Westbound",
"Southbound",
"Eastbound"
]
let foundOne=0;
if(searchTerms.some(function(v){return str.indexOf(v)>=0;})){
foundOne=1;
}
if(foundOne==0){
Email.sendMeEmail.skip();
}
I have looked at the Twitter API, but that is a step too far for my coding ability which is why I'm using IFTTT.
Any help is very much appreciated
Thank you.
I'm playing with IFTTT Filter myself at the moment, so here are some thoughts about solving your solution.
If you want to do a case insensitive seatch on the original text, convert the original text to lowercase, then have all your search terms in lowercase.
Plus I think you want to iterate over the searchTerms array, and use the includes() method. Ok, just realised that .some() does the iteration for you, but I prefer includes() over indexof().
let str=Twitter.newTweetFromSearch.Text.toLowerCase();
let searchTerms=[
"northbound",
"westbound",
"southbound",
"eastbound"
]
let foundOne=0;
if(searchTerms.some(function(term){return str.includes(term);})){
foundOne=1;
}
if(foundOne==0){
Email.sendMeEmail.skip();
}
Or you could just skip having the foundOne variable, and do the search in the if() statement.
let str=Twitter.newTweetFromSearch.Text.toLowerCase();
let searchTerms=[
"northbound",
"westbound",
"southbound",
"eastbound"
]
if(!searchTerms.some(function(term){return str.includes(term);})){
Email.sendMeEmail.skip();
}
I m trying to implement autocomplete in my application.
say I have the following documents:
"red smart phone"
"super smart phone"
"small bluetooth speaker"
So when the user types "s" I need to return as suggestions:
"smart"
"small"
Currently I m using simple highlight in Elasticsearch to get the matched words (smart, small). However the thing is that I get back 2 times the "smart". Is it possible to configure ES return only distinct values for the Highlight?
On top of that is it possible to let ES return also the next (n) word(s) , e.g.:
"smart phone"
"small bluetooth (speaker)"
The completion suggester seems to be the solution for your need:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html
You have to modify your ES mapping to add new properties on your field.
Be careful of your analyzer too.
HtH,
NicolasY.
Is there posibilities to load only that terms what i am looking for ? Example if i search [ expert ] word it will look in suggested_tags and output result according to that ?
Right now if i type child it takes all terms and it makes file size big and it takes time to show autocomplete.
Here is Image
When we search in google it shows result like this :
Google Output
So it is possible in elasticsearch ? because i don't want to load all suggested_tags while searching only load 4 or 5 related to search and doesn't metter for position.
Thanks
I am trying to study some rethinkdb for my next project. My backend is in Haskell and rethink db haskell driver looks a bit better then mongodb. So I want to try it.
My question is how do you do simple text search with rethinkdb?
Nothing too complex. Just find field which value contains these words.
I assume this should be built in as even a smallest blog app needs a search facility of some kind, right?.
So I am looking for a mongodb equivalent of:
var search = { "$text": { "$search": "some text" } };
Thank you.
EDIT
I am not looking for regular expressions and the match function.
It is extremely slow for more or less large sets.
I does not have any notion of indexes.
It does not have any notion of stemming.
With the rethinkdb driver documented here
run h $ table "table" # R.filter (\row -> match "some text" (row ! "field"))
If I use the wordforms file, to a word like this:
television > tv
If i search for television, i'd get results with TV on it, but i also want to have television results, is that possible?
Yes, that's how it works by default. But, you have to rebuild your index after changing the word forms. The mapping occurs at both index time and query time.