Select2: Display all search results which contain the characters in sequence - jquery-select2

I want to use select2 search such that it also displays results which do not match the options strictly.
Eg. If hello world is present in the select box, typing hl or hw should return hello world as search result.

The default matcher provided by Select2 does exact searches, but it can be extended to do custom matching.
A matcher like you are looking for can be found at this pull request.

Related

OR Operator in Google Sheets Not Working?

This is the formula I am working on right now:
=FILTER(Data!A:K, SEARCH("Gretsch", Data!F:F)+SEARCH("Krutz", Data!F:F))
I'm trying to bring in both rows that include "Gretsch" and rows that include "Krutz". Just using one of those instead of both works just fine, and using keywords that the other has included in it's results (for example, searching just Gretsch brings up 10 or so (out of the 100+) products that include "Streamliner" in the F Column, as well as Gretsch, so using this formula:
=FILTER(Data!A:K, SEARCH("Gretsch", Data!F:F)+SEARCH("Streamliner", Data!F:F))
brings up the 10 or so products with both, but I'm looking for one OR the other, so why is that '+' acting like an AND operator instead? Am I just completely off base?
SEARCH returns a number: the starting position where a string is found within another string. It's not a simple 1 like other tests for TRUE, and there is no 0 case (i.e., FALSE) as you have it written. In addition, if either SEARCH does not find the target string, it returns an error; and a number plus an error... returns an error (which is not TRUE and therefore will not be included in the FILTER).
A better approach to achieving OR with FILTER:
=FILTER(Data!A:K, REGEXMATCH(LOWER(Data!F:F),"gretsch|krutz"))
The pipe symbol ("|") means OR in this context, and you may list as many pipe-separated strings as you like. Notice that the search range is wrapped in LOWER and that the terms to search are also lowercase; this assures the same kind of caps-agnostic search you were looking for with SEARCH.
By the way, based on your other recent post, you can also use REGEXMATCH with NOT, e.g.:
=FILTER(Data!A:K, REGEXMATCH(LOWER(Data!F:F),"gretsch|krutz"), NOT(REGEXMATCH(LOWER(Data!F:F),"case")))
One additional note: Your post is tagged "Excel" and "Google Sheets." The formulas I've proposed will only work with Google Sheets. In most cases by far, it is best to tag a post here with either "Excel" or "Google Sheets" but not both, since the differences are substantial between the two.
try:
=QUERY(Data!A:K, "where lower(F) contains 'gretsch'
or lower(F) contains 'krutz'")

JQL actual "contains"

I want to perform a simple search on a text field with part of its content but I don't know the beginning. I basically want what someone would expect of a "contains search". If I search issue for 345, I would want this result:
123456
234567
345678
...
Which, in JQL, would be the result of the query issue ~ "*345*", but the * is not allowed as first character in wildcard query. Is there an easy way to get this result, preferably with a JQL query?
Right now it's impossible to search JIRA for contains operation. As described in Search syntax for text fields, JIRA support Word stemming:
Since JIRA cannot search for issues containing parts of words, word
'stemming' allows you to retrieve issues from a search based on the
'root' (or 'stem') forms of words instead of requiring an exact match
with specific forms of these words. The number of issues retrieved
from a search based on a stemmed word is typically larger, since any
other issues containing words that are stemmed back to the same root
will also be retrieved in the search results.
That means, that you can search for common root of some word, but can't search for arbitrary part of it.
There is an issue in official JIRA bug tracker: Allow searching for part of a word (prefix / substring searches), which describes why this can't be implemented:
Lucene doesn't support prefix search.
As a workaround the suggestion is to use Script Runner plugin for JIRA:
issueFunction in issueFieldMatch("project = JRA", "description", "ABC\\d{4}")
See more on IssueFieldMatch here.
Another plugin, which can do regex jql is JQL Search Toolkit.
Filter issues by "345" substring in the Summary field:
summary ~ "345"
Filter issues by "345" substring in the Description field:
description ~ "345"

TableSorter consecutive search

It appears that tablesorter needs filter terms to match consecutively.
For example:
A column contains: "Safe Rigging Practices for Seafarers"
Filter:
"Safe" returns the column
"Safe Rigging" returns the column
"Safe Practices" does not return the column.
Is there an option to change this behavior?
When you use a basic filter search, it only looks for a match of the query (from left-to-right), as you have stated above.
The filter widget also includes several different search types. See a full list in the docs at the top of this demo page. Here are several ways to get the results you desire:
As #vesuvious guessed, the search also supports wildcards, but in this case it uses an asterisk (*) to replace entire words (not including spaces). So try searching for:
Safe * Practices
You could also use a logical AND by separating words using two ampersands (&&), or the word "and" (case insensitive). Both must be surrounded by spaces:
Safe && Practices
Safe and Practices
Lastly, you can use a fuzzy search to get the result by starting the search with a tilde (~):
~Safe Practices

Google Search Appliance wildcard character support

Does Google Search Appliance support wildcard characters in the query string. If no, is there any way I can fetch all the result set through my query?
The GSA does not support wildcarding. An option can be toN-Gram the fields or content that you want wildcarded. This would be achieved in your feeder or pipeline.
If waiting and upgrading the gsa software to v 7.2,.coming mid December is an option you will have wild card search built in.
Otherwise you have to dig deeper. A possible option is a document filter. If you are interested in that option I might be able to help.
I have developed such a document filter.
GSA software 7.4 has wildcard search built in. From documentation:
Enabling Wildcard Search
Wildcard search is a feature that enables your users to search by entering a word pattern rather than the exact spelling of a term. The search appliance supports two wildcard operators:
*--Matches zero or more characters
?--Matches exactly 1 character
Using wildcards can simplify queries for long names, technical data, pharmaceutical information, or strings where the exact spelling varies or is unknown. A user can search for all words starting with a particular pattern, ending with a particular pattern, or having a particular substring pattern.
By default, wildcard indexing is disabled for your search appliance. You can enable or disable wildcard indexing by using the Index > Index Settings page. You can disable or enable wildcard search for one or more front ends by using the Filters tab of the Search > Search Features > Front Ends page.
One way to get all indexed items from a collection is to use a query that will match every indexed record, e.g., supposing you're indexing some set of URLs from subdomain.companyname.com, just query for "companyname", with the "&num=1000&filter=0" query string parameters.

Using Lucene Highlighter along with MultiFieldQueryParser

Im using Lucene Highlighter to highlight the matches that I have found in a Lucene Index. Now, my problem is that If I have to search multiple fields of a document, and I need to display the matching text, then how can I get in which field the hit has occurred?
The code which I am using for the highlighter is basically the second function here
If I do not know in which field the hit has occurred in, then what field do I pass to the function defined above to get the matching fragments?
You could combine the fields into a single text field and run your highlighter on it.

Resources