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
2 answers

PHP: How to search a file using wildcards

I need to read a file in PHP, but I only know the end of the filename, so I need to serch the file in a given directory using wildcards: *filename.wav and then return it to the browser. Is there a function to do that? or I need to get all the files…
doc
  • 269
  • 1
  • 4
  • 15
11
votes
2 answers

How does OEIS do subsequence search?

The Online Encyclopedia of Integer Sequences supports search for sequences containing your query as a subsequence, eg. searching for subseq:212,364,420,428 will return the 8*n+4 sequence. (http://oeis.org/search?q=subseq:212,364,420,428) This…
Thomas Ahle
  • 30,774
  • 21
  • 92
  • 114
11
votes
1 answer

wireshark search tcp stream for string

I need to be able to search all tcp streams that contain a particular string, not just a particular packet. Something like: tcp.stream contains "string" I need to do this in order to filter out all streams containing a certain string to get exactly…
Zach Ogden
  • 111
  • 1
  • 1
  • 3
11
votes
5 answers

Find and replace a particular term in multiple files

How can I replace a particular term in multiple files in Linux? For instance, I have a number of files in my directory: file1.txt file2.txt file3.txt And I need to find a word "searchword" and replace it with "replaceword".
Legend
  • 113,822
  • 119
  • 272
  • 400
11
votes
1 answer

Spatial data structure for finding all points greater than or less than a value in each cartesian dimension

I am currently working on an optimization problem that requires finding all points greater than (or in some cases less than) a particular point in all cardinal directions. For example, in 2D, I might need to find all points that satisfy the…
MarkD
  • 4,864
  • 5
  • 36
  • 67
11
votes
3 answers

Javascript Search Engine (Search own site)

I want to have a search engine which searches only my own site. I have some JavaScript currently, but it only searches words on that specific page. I need it to search the links within my site if possible. I cannot use the Google search engine as…
Samp
  • 385
  • 3
  • 4
  • 14
11
votes
2 answers

Speeding up a search for best binary matching number

I have an array of 256-bit values. The array is huge (millions of records) but it is modified just rarely and it fits to the memory. For a given 256-bit number I want to find whether there exists a record which has at least N bits equal. For…
smrt28
  • 469
  • 3
  • 20
11
votes
2 answers

Implementing full text search on iPhone?

I'm looking for suggestions on the best way to implement a full-text search on some static data on the iPhone. Basically I have an app that contains the offline version of a web site, about 50MB of text, and I'd like for users to be able to search…
Nimrod
  • 5,168
  • 1
  • 25
  • 39
11
votes
4 answers

Google-like search query tokenization & string splitting

I'm looking to tokenize a search query similar to how Google does it. For instance, if I have the following search query: the quick "brown fox" jumps over the "lazy dog" I would like to have a string array with the following…
jamesaharvey
  • 14,023
  • 15
  • 52
  • 63
11
votes
3 answers

Search a string as you type the character

I have contacts stored in my mobile. Lets say my contacts are Ram Hello Hi Feat Eat At When I type letter 'A' I should get all the matching contacts say "Ram, Feat, Eat, At". Now I type one more letter T. Now my total string is "AT" now my…
user875036
  • 319
  • 2
  • 12
11
votes
2 answers

elasticsearch prefix query for multiple words to solve the autocomplete use case

How do I get elastic search to work to solve a simple autocomplete use case that has multiple words? Lets say I have a document with the following title - Elastic search is a great search tool built on top of lucene. So if I use the prefix query…
user1796571
  • 662
  • 2
  • 9
  • 21
11
votes
4 answers

Rails ActiveRecord: Multiple conditions in find

This might be more of a Ruby syntax thing than anything else. I'm having difficulty getting two limiting conditions on a SomeObject.find going. Separated, the conditions seem to work: if search != '' find(:all, :conditions => ['name LIKE ?',…
Will Matheson
  • 338
  • 1
  • 4
  • 19
11
votes
4 answers

How to check against all joins when generating a score using MYSQL

I'm using MYSQL to generate a score for each result returned by a query. The results are then ordered by the score. The part that doesn't seem to be working properly is when I'm trying to add a score for each tag that has been searched and the…
Martin Hunt
  • 1,135
  • 2
  • 14
  • 23
11
votes
7 answers

WildcardQuery error in Solr

I use solr to search for documents and when trying to search for documents using this query "id:*", I get this query parser exception telling that it cannot parse the query with * or ? as the first character. HTTP Status 400 -…
cnu
  • 36,135
  • 23
  • 65
  • 63
11
votes
6 answers

php array_search 0 index

It seems that that you can not use the search_array function in PHP to search the 0 index AND have it evalute as true. Consider this code for example: $test=array(100, 101, 102, 103); if($key=array_search(100,$test)){ echo $key; } else{ …
anon