Questions tagged [search]

Questions about search algorithm mechanics and implementation. *NOT* for questions about using search tools within an API (e.g. Google, Bing, Facebook).

Searching is one of the most common and important tasks in Computer Science.

The most basic search algorithm is a (also called "sequential search"). Each item in a collection of data is examined in sequence until the sought item is found.

If the collection in question has already been sorted, for instance, then a more efficient is possible.

Search can become more complex when, rather than finding one instance of a specific item, we want to find all items meeting a certain set of criteria. For instance a query can specify extremely complex search criteria, and much of relational database design involves the planning of an efficient way to perform those searches.

Another more complex search scenario is graph search, in which a series of nodes and edges must be traversed. Common algorithms for this domain include and . In many cases, a heuristic search algorithm such as can achieve more efficient results by making use of additional information about the problem.


Do not use this tag for questions about specific search tools within an API. Some more relevant tags for that would be the following:

37207 questions
11
votes
5 answers

Algorithm that searches for related items based on common tags

Lets take StackOverflow questions as example. Each of them has multiple tags assigned. How to build an algorithm that would find related questions based on how many common tags they have (sorted by number of common tags)? For now I can't think about…
serg
  • 109,619
  • 77
  • 317
  • 330
11
votes
1 answer

Ransack, search multiple columns, one field, rails 3

I'm new to Ruby on Rails, and I'm creating my first site. I have a user model with 3 columns: firstname, lastname and email. Im using ransack to make a search engine, and i want to have one search field that will go through every column and display…
Remi Champ
  • 223
  • 1
  • 2
  • 6
11
votes
2 answers

Using grep recursively

grep has the ability to search recursively using the -r option. However, I was wondering if grep has the ability to search for a query string recursively for a specified number of subfolder levels. For instance, I have a folder root which has…
Sal
  • 3,179
  • 7
  • 31
  • 41
11
votes
7 answers

Algorithm Optimization - Shortest Route Between Multiple Points

Problem: I have a large collection of points. Each of these points has a list with references to other points with the distance between them already calculated and stored. I need to determine the shortest route that begins from an origin and…
Chris Douglass
  • 309
  • 1
  • 3
  • 11
11
votes
17 answers

checking if the first letter of a word is a vowel

I am trying to use python to write a function that checks whether the first letter of a given word, for instance "ball" is a vowel in either uppercase or lowercase. So for instance: #here is a variable containing a word: my_word =…
Bola Owoade
  • 119
  • 1
  • 1
  • 4
11
votes
3 answers

What is the algorithm for query search in the database?

Good day everyone, I'm currently doing research on search algorithm optimization. As of now, I'm researching on the Database. In a database w/ SQL Support. I can write the query for a specific table. Select Number from Table1 where Name =…
Treize
  • 417
  • 2
  • 5
  • 9
11
votes
6 answers

Better way to find index of item from ArrayList

First of all, please correct me If I am wrong. I want to find index of Item (i.e String value) from ArrayList without using For Loop. POJO: id; name; Code: ArrayList list = new ArrayList; //Lots of data added to these…
Scorpion
  • 6,831
  • 16
  • 75
  • 123
11
votes
2 answers

How to use n-grams approximate matching with Solr?

We have a database of movies and series, and as the data comes from many sources of varying reliability, we'd like to be able to do fuzzy string matching on the titles of episodes. We are using Solr for search in our application, but the default…
Ryszard Szopa
  • 5,431
  • 8
  • 33
  • 43
11
votes
3 answers

Fulltext search on mysql with a 3 letter word

I'm trying to find "the zen" string in a field containing "The Zen Circus". I've got a FULLTEXT index. select url,name, , MATCH(name) AGAINST ( 'zen*' IN BOOLEAN MODE) as A , MATCH(name) AGAINST ( '"the zen*"' IN BOOLEAN MODE) as B , …
Pons
  • 1,747
  • 1
  • 13
  • 19
11
votes
2 answers

PHP, MySQL, Efficient tag-driven search algorithm

I'm currenlty building a webshop. This shop allows users to filter products by category, and a couple optional, additional filters such as brand, color, etc. At the moment, various properties are stored in different places, but I'd like to switch to…
Ruben Vreeken
  • 956
  • 1
  • 13
  • 22
11
votes
4 answers

Search column in SQL database ignoring special characters

Does anybody know if it's possible to do a %LIKE% search against a column in a SQL Server database but get it to ignore any special characters in the column? So, for example if I have a column called "songs" and they contain the following... Black…
jonhobbs
  • 26,684
  • 35
  • 115
  • 170
11
votes
1 answer

Chrome 22 Developer Tools - Global Sources Search not working right (ctrl-shift-f)

this morning I noticed my Chrome updated to Chrome 22 and that the search in the top right has been removed and can now be accessed with ctrl-f. I also noticed that ctrl-shift-f is no longer working as expected... (but this is inconsistent) The…
ilovett
  • 3,240
  • 33
  • 39
11
votes
3 answers

Identifying a person's name vs. a dictionary word

Is there some way to recognize that a word is likely to be/is not likely to be a person's name? So if I see the word "understanding" I would get a probability of 0.01, whereas the word "Johnson" would return a probability of 0.99, while a word like…
Jordan Reiter
  • 20,467
  • 11
  • 95
  • 161
11
votes
1 answer

In Visual Studio 2010 search for two strings within single lines of c# code

I am using Visual Studio 2010 with c#. I need to search my codebase for find all lines of code where two strings are found in the single line of code (the line of code could span multiple lines which c# allows). The two strings are not connected…
user31673
  • 13,245
  • 12
  • 58
  • 96
11
votes
3 answers

How to use TermVector Lucene 4.0

In the indexing method I use the following line: Field contentsField = new Field("contents", new FileReader(f), Field.TermVector.YES); However, in Lucene 4.0 this constructor is deprecated and new TextField should be used instead of new Field. But…
user692704
  • 544
  • 6
  • 21