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
9
votes
5 answers

Searching in Ruby on Rails - How do I search on each word entered and not the exact string?

I have built a blog application w/ ruby on rails and I am trying to implement a search feature. The blog application allows for users to tag posts. The tags are created in their own table and belong_to :post. When a tag is created, so is a record in…
bgadoci
  • 6,363
  • 17
  • 64
  • 91
9
votes
2 answers

R - Find every location of a string in a data frame

I have a data frame that looks like this: a <- c("jan", "mar", "jan", "feb", "feb") b <- c("feb", "mar", "mar", "jan", "mar") c <- c("jan", "feb", "feb", "jan", "jan") d <- c("jan", "mar", "jan", "feb", "feb") e <- c("feb", "jan", "feb", "mar",…
jdfinch3
  • 513
  • 1
  • 7
  • 18
9
votes
2 answers

Algolia vs Solr search

I'm building a product search platform. I used Solr search engine before, and i found its performance is fine but doesn't generate a user interface. Recently I found Algolia has more features, easy setup, and generates a User Interface. So if…
mah.aziz
  • 177
  • 1
  • 6
9
votes
2 answers

Search query to retrieve nested documents in elasticsearch with _source disabled

I have the following mapping { "cloth": { "dynamic" : false, "_source" : {"enabled" : false }, "properties": { "name": { "type": "string", "index": "analyzed" …
user1760178
  • 6,277
  • 5
  • 27
  • 57
9
votes
1 answer

MongoDB: $or a full-text search and an $in

The problem Hi. I have what seems to me as a strange problem and I'm at a loss with it: Let's take: tags = [ ObjectId('a'), ObjectId('b') ] search = { $search: 'abc' } Now the following query works fine: db.entries.find({ $or: [ {$text:search} ]…
Avaq
  • 3,009
  • 1
  • 21
  • 25
9
votes
6 answers

How to search for multiple strings in a file

I want to search for the occurrence of string1 OR string2 OR string3, etc. in a file, and print only those lines (to stdout or a file, either one). How can I easily do this in bash?
topwoman
  • 91
  • 1
  • 1
  • 2
9
votes
6 answers

C# Search for subdirectory (not for files)

Every example I see seems to be for recursively getting files in subdirectories uses files only. What I'm trying to do is search a folder for a particular subdirectory named "xxx" then save that path to a variable so I can use it for other things.…
Brad
  • 1,684
  • 4
  • 20
  • 36
9
votes
1 answer

Lucene Proximity Search for phrase with more than two words

Lucene's manual has explained the meaning of proximity search for a phrase with two words clearly, such as the "jakarta apache"~10 example in http://lucene.apache.org/core/2_9_4/queryparsersyntax.html#Proximity Searches However, I am wondering what…
dwdwdw
  • 93
  • 1
  • 3
9
votes
4 answers

How can i fix "Googlebot can't access your site" issue?

I just keep getting a message about "Over the last 24 hours, Googlebot encountered 1 errors while attempting to access your robots.txt. To ensure that we didn't crawl any pages listed in that file, we postponed our crawl. Your site's overall…
Jason
  • 221
  • 2
  • 3
  • 7
9
votes
7 answers

Searchable list of objects in Java

I want to create a large (~300,000 entries) List of self defined objects of the class Drug. Every Drug has an ID and I want to be able to search the Drugs in logarithmic time via that ID. What kind of List do I have to use? How do I declare that it…
Christian
  • 25,249
  • 40
  • 134
  • 225
9
votes
4 answers

How do you run Lucene on .net?

Lucene is an excellent search engine, but the .NET version is behind the official Java release (latest stable .NET release is 2.0, but the latest Java Lucene version is 2.4, which has more features). How do you get around this?
Kalid
  • 22,218
  • 14
  • 44
  • 46
9
votes
3 answers

Find array index if given value

I want to retrieve the index in the array where the value is stored. I know the value of the item at that point in the array. I'm thinking it's similar to the findIndex function in c#. For example, array[2] = {4, 7, 8}. I know the value is 7, how do…
user1798299
  • 173
  • 2
  • 4
  • 12
9
votes
2 answers

Implement smart search / Fuzzy string comparison

I have a web page on an ASP.NET MVC application where customers search for suppliers. The suppliers capture their own details on the website. The client wants a "smart search" feature, where they could search for suppliers and find them even if the…
Carel
  • 2,063
  • 8
  • 39
  • 65
9
votes
4 answers

How do I speed up recursive search function?

I am having trouble with the speed of the search function that I wrote. The function steps are described below: The function begins with two table name parameters, a starting-point and a target The function then traverses a list of table-column…
Sinker
  • 576
  • 1
  • 7
  • 21
9
votes
2 answers

Algorithm to find common substring across N strings

I'm familiar with LCS algorithms for 2 strings. Looking for suggestions for finding common substrings in 2..N strings. There may be multiple common substrings in each pair. There can be different common substrings in subsets of the strings. strings:…
Dwight Kelly
  • 1,232
  • 2
  • 11
  • 17