startswith

Lucens best way to do “starts-with” queries

萝らか妹 提交于 2019-12-07 16:31:18
问题 I want to be able to do the following types of queries: The data to index consists of (let's say), music videos where only the title is interesting. I simply want to index these and then create queries for them such that, whatever word or words the user used in the query, the documents containing those words, in that order, at the beginning of the tile will be returned first, followed (in no particular order) by documents containing at least one of the searched words in any position of the

Why is this Lucene query a “contains” instead of a “startsWith”?

为君一笑 提交于 2019-12-07 04:51:18
问题 string q = "m"; Query query = new QueryParser("company", new StandardAnalyzer()).Parse(q+"*"); will result in query being a prefixQuery :company:a* Still I will get results like "Fleet Africa" where it is rather obvious that the A is not at the start and thus gives me undesired results. Query query = new TermQuery(new Term("company", q+"*")); will result in query being a termQuery :company:a* and not returning any results. Probably because it interprets the query as an exact match and none of

Lucens best way to do “starts-with” queries

主宰稳场 提交于 2019-12-05 18:42:00
I want to be able to do the following types of queries: The data to index consists of (let's say), music videos where only the title is interesting. I simply want to index these and then create queries for them such that, whatever word or words the user used in the query, the documents containing those words, in that order, at the beginning of the tile will be returned first, followed (in no particular order) by documents containing at least one of the searched words in any position of the title. Also all this should be case insensitive. Example: For documents: Video1Title = Sea is blue

Why is this Lucene query a “contains” instead of a “startsWith”?

落爺英雄遲暮 提交于 2019-12-05 10:43:36
string q = "m"; Query query = new QueryParser("company", new StandardAnalyzer()).Parse(q+"*"); will result in query being a prefixQuery :company:a* Still I will get results like "Fleet Africa" where it is rather obvious that the A is not at the start and thus gives me undesired results. Query query = new TermQuery(new Term("company", q+"*")); will result in query being a termQuery :company:a* and not returning any results. Probably because it interprets the query as an exact match and none of my values are the "a*" literal. Query query = new WildcardQuery(new Term("company", q+"*")); will

Dplyr select_ and starts_with on multiple values in a variable list

有些话、适合烂在心里 提交于 2019-12-05 01:22:00
I am collecting data from differnt sensors in various locations, data output is something like: df<-data.frame(date=c(2011,2012,2013,2014,2015),"Sensor1 Temp"=c(15,18,15,14,19),"Sensor1 Pressure"=c(1001, 1000, 1002, 1004, 1000),"Sensor1a Temp"=c(15,18,15,14,19),"Sensor2 Temp"=c(15,18,15,14,19),"Sensor2 Pressure"=c(1001, 1000, 1002, 1004, 1000)) The problem is (I think) similar to: Using select_ and starts_with R I want to search for sensors for example by location so I have a list to search through the dataframe and also include the timestamp. But searching falls apart when I search for more

LINQ to SQL query where a string StartsWith an element from a generic list

霸气de小男生 提交于 2019-12-03 23:35:34
问题 I'm looking to update one of my queries as the requirements for the search has changed. Originally, the user was to enter a single SKU and a mfg. date range to search the product catalog. So this is what I used. DateTime startDate = ...; DateTime endDate = ...; string prodSKU = TextSKU.Text.Trim(); var results = from c in db.Products where c.is_disabled == false && c.dom >= startDate && c.dom <= endDate && c.sku.StartsWith(prodSKU) select c; Now the requirement says that the user can enter a

If strings starts with in PowerShell [duplicate]

僤鯓⒐⒋嵵緔 提交于 2019-12-03 22:11:35
This question already has an answer here: Check first character of each line for a specific value in PowerShell 4 answers Is there a way to check if a string starts with a string? We are checking the groupmembership from the AD user. Our AD groups look like this: S_G_share1_W The script for connecting the networkshares should only run if the groupname starts with "S_G_" , because we have some other groups too. $GroupArray = Get-ADPrincipalGroupMembership $env:USERNAME | select samaccountname foreach ($Group in $GroupArray) { if ($Group.StartsWith("S_G_")) { $Group = $Group -replace "S_G_",

How do I ignore case when using startsWith and endsWith in Java? [duplicate]

≯℡__Kan透↙ 提交于 2019-12-03 20:34:23
问题 This question already has answers here : startsWith() method of string ignoring case (7 answers) Closed 2 years ago . Here's my code: public static void rightSel(Scanner scanner,char t) { /*if (!stopping)*/System.out.print(": "); if (scanner.hasNextLine()) { String orInput = scanner.nextLine; if (orInput.equalsIgnoreCase("help") { System.out.println("The following commands are available:"); System.out.println(" 'help' : displays this menu"); System.out.println(" 'stop' : stops the program");

Why is function isprefix faster than Startswith in C#?

泄露秘密 提交于 2019-12-03 08:47:57
问题 Does anyone know why C# (.NET)'s StartsWith function is considerably slower than IsPrefix? 回答1: I think it's mostly fetching the thread's current culture. If you change Marc's test to use this form of String.StartsWith : Stopwatch watch = Stopwatch.StartNew(); CultureInfo cc = CultureInfo.CurrentCulture; for (int i = 0; i < LOOP; i++) { if (s1.StartsWith(s2, false, cc)) chk++; } watch.Stop(); Console.WriteLine(watch.ElapsedMilliseconds + "ms; chk: " + chk); it comes a lot closer. If you use

Elasticsearch “starts with” first word in phrases

自古美人都是妖i 提交于 2019-12-03 02:00:46
I try to implement an A - Z navigation for my content with Elasticsearch. What I need, is displaying all results which begins with e.g. a,b,c,... etc. I've tried: "query": { "match_phrase_prefix" : { "title" : { "query" : "a" } } } The query mentioned above also display results, where within the string a word begins with a. Example: "title": "Apfelpfannkuchen", "title": "Affogato", "title": "Kalbsschnitzel a n A ceto Balsamico", I want to display only phrase where the FIRST word begins with a. Here the mapping I use: $params = array( 'index' => 'my_index', 'body' => array( 'settings' => array(