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
10
votes
3 answers

Optimized argmin: an effective way to find an item minimizing a function

Let us say I've got a collection of items and a score function on them: struct Item { /* some data */ }; std::vector items; double score(Item); I'd like to find the item from that collection whose score is the lowest. An easy way to write…
YSC
  • 38,212
  • 9
  • 96
  • 149
10
votes
1 answer

UISearchController in NavigationItem iOS 11 Apple way

In iOS 11 Apple presented new search bar, but yet in iOS 11.2.2 developer have push\pop animation bug when both view controllers have searchController. Apple demonstrate their vision in Files app. Do someone know how do it? edit#1 Question with…
10
votes
4 answers

How-to: Ranking Search Results

I have a webapp development problem that I've developed one solution for, but am trying to find other ideas that might get around some performance issues I'm seeing. problem statement: a user enters several keywords/tokens the application searches…
warren
  • 32,620
  • 21
  • 85
  • 124
10
votes
2 answers

What makes Everything's file search and index so efficient?

Everything is a file searching program. As its author hasn't released the source code, I am wondering how it works. How could it index files so efficiently? What data structures does it use for file searching? How can its file searching be so…
Sraw
  • 18,892
  • 11
  • 54
  • 87
10
votes
2 answers

Robots.txt priority question

If I have these lines in robots.txt: Disallow /folder/ Allow /folder/filename.php Will the filename.php be allowed then? Which order does google prioritize the lines? What will happen here for example?: Allow / Disallow / I am mainly referring to…
user188962
10
votes
2 answers

Finding the position of words in a string

My Task I am trying to find the position of words appearing in a string using regex Code import re # A random string mystr = "there not what is jake can do for you ask what you play do for spare jake".upper() match =…
Enigmatic
  • 3,902
  • 6
  • 26
  • 48
10
votes
3 answers

Find/Grep in all VI buffers

With many buffers open, I need a simple way to search all buffers for a regex and navigate the search result (quick list?) I know I can :bufdo command, and it is easy to search and replace with %s, but I can't find a way to do just a simple search…
Samer Buna
  • 8,821
  • 9
  • 38
  • 55
10
votes
2 answers

Searching Arabic names discard the differences between "أ" , "ا" in mysql

I am storing Arabic name in my database. In Arabic there are some letters that may written in different format such as "ا"، "أ"، "آ" it all represent the same letter. Also, "ه" ، "ة". I need to search database for names and ignoring the differences…
A. Gh
  • 111
  • 1
  • 5
10
votes
3 answers

RavenDB full-text search

Can you please tell how to perform simple full-text search in RavenDb. The database is stored document: Movie {Name = "Pirates of the Carribean"}. I wish that this document was found on the search phrase "Pirates Carribean" or any other combination…
Boris Mitchenko
  • 880
  • 9
  • 18
10
votes
1 answer

Searching array reports "not found" even though it's found

This is a generic question and answer for a logical error I've seen in many questions from new programmers in a variety of languages. The problem is searching an array for an element that matches some input criteria. The algorithm, in pseudo-code,…
Barmar
  • 741,623
  • 53
  • 500
  • 612
10
votes
3 answers

How to optimize date time search in Mysql?

this is my basic date-time structure: primary key(datetime) key auot_id date_time user_id 1 2010-10-01 20:32:34 1 2 2010-10-02 20:32:34 1 3 2010-11-03 20:32:34 2 4 2010-10-04 20:32:34 1 5…
qinHaiXiang
  • 6,051
  • 12
  • 47
  • 61
10
votes
1 answer

Searching through an alias with filter is very slow in Elasticsearch

I have an elasticsearch index, my_index, with millions of documents, with key my_uuid. On top of that index I have several filtered aliases of the following form (showing only my_alias as retrieved by GET my_index/_alias/my_alias): { "my_index":…
yannisf
  • 6,016
  • 9
  • 39
  • 61
10
votes
3 answers

Faster way to see if a huge list of strings is contained within another string

I have a list of around 300k common words stored in an array. So, 1 element of the array = 1 word. On the other side, I have a huge list of strings that MAY contain one or more of these 300k words inside them. A sample string would be:…
anemaria20
  • 1,646
  • 2
  • 17
  • 36
10
votes
6 answers

Search for commented-out code across files in Eclipse

Is there a quick way to find all the commented-out code across Java files in Eclipse? Any option in Search, perhaps, or any add-on that can do this? It should be able to find only code which is commented out, but not ordinary comments.
akjain
  • 1,787
  • 3
  • 20
  • 35
10
votes
2 answers

How to improve the performance of Leetcode 4sum-ii challenge

It is a leet code contest question which I am trying to attempt after contest is over but my code always exceeds time limit. Question is Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that…
Ali Mohsan
  • 326
  • 2
  • 15