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
8
votes
7 answers

Searching an array for integers in a specific range

Can someone give me ideas for the following problem? Given an array ar[] of length n, and some queries, each query is of the form a, b, c, find the number with the smallest index i such that the index lies in the range [c, n] and such that a < ar[i]…
Chris
  • 26,544
  • 5
  • 58
  • 71
8
votes
6 answers

Given a string, find all its permutations that are a word in dictionary

This is an interview question: Given a string, find all its permutations that are a word in dictionary. My solution: Put all words of the dictionary into a suffix tree and then search each permutation of the string in the tree. The search time…
user1002288
  • 4,860
  • 10
  • 50
  • 78
8
votes
2 answers

finding element of numpy array that satisfies condition

One can use numpy's extract function to match an element in an array. The following code matches an element 'a.' exactly in an array. Suppose I want to match all elements containing '.', how would I do that? Note that in this case, there would be…
Faheem Mitha
  • 6,096
  • 7
  • 48
  • 83
8
votes
2 answers

Extract X number of words surrounding a given search string within a string

I am looking for a way to extract X number of words on either side of a given word in a search. For example, if a user enters "inmate" as a search word and the MySQL query finds a post that contains "inmate" in the content of the post, I would like…
programmer guy
  • 123
  • 3
  • 9
8
votes
2 answers

Fast, line-wise "grep -n" equivalent for Unix directory structure

I am trying to create a web interface for searching through a large number of huge configuration files (approx 60000 files, each one with a size between 20 KByte to 50 MByte). Those files are also updated frequently (~3…
knipknap
  • 5,934
  • 7
  • 39
  • 43
8
votes
0 answers

Fuzzy Street Address Searches Using MySQL Fulltext (or sphinx?)

I have a database table full of addresses from Google Maps geocode responses. Google abbreviates all directions (West -> W, East -> E, etc). So if I enter an address like "100 West Pender Street" then the formatted address returned by Google Maps is…
emh
  • 1,279
  • 3
  • 15
  • 26
8
votes
1 answer

Dynamic column names using DIH (DataImportHandler)

Is there a way to create dynamic column (as a key/value) names using the values returned from the query throw DIH (DataImportHandler)? For example:
Ehab Al-Hakawati
  • 982
  • 4
  • 11
  • 32
8
votes
4 answers

Is a kd-tree suitable for 4D space-time data (x,y,z,time)?

I want to use a data structure for sorting space-time data (x,y,z,time). Currently a processing algorithm searches a set of 4D (x,y,z,time) points, given a spherical (3d) spacial radius and a linear (1d) time radius, marking for each point, which…
user44484
8
votes
2 answers

facet dynamic fields with apache solr

I have defined dynamic field in ApacheSolr: I use it to store products features like: color_feature, diameter_feature, material_feature and so on. Number of those fields are not constant becouse products are changing. Is it possible to get facet…
krinn
  • 882
  • 2
  • 10
  • 16
8
votes
2 answers

LIKE wildcard with multiple fields and spaces in MYSQL

I'm having some trouble searching for any similar match in two fields. For example I have a table with the values: CAR MAKE CAR MODEL Ford Mustang (Shelby) Toyota Corolla Seat Leon etc etc. I want to be able to get the result…
penpen
  • 935
  • 3
  • 12
  • 22
8
votes
2 answers

Javascript str.search() multiple instances

How can I retrieve multiple indexes from multiple instances of a string search? var str = "food"; var index1 = str.search("o"); // 1 var index2 = str.search("o"); // ? Thanks much, Wen
Wenn
  • 339
  • 2
  • 4
  • 14
8
votes
2 answers

Ignore HTML characters when searching HTML stored content PHP/MySQL?

We are storing blocks of HTML content in MySQL (it is formatted text created in CKeditor. Ckeidor adds inline CSS styles to format the text). We are storing the database in a column called "page_content" We want a search feature that allows users…
user635800
  • 193
  • 2
  • 9
8
votes
7 answers

How to implement incremental search on a list

I want to implement incremental search on a list of strings. Consider I have an array containing which contains the strings store,state,stamp,crawl,crow. My application has a text box in which the user enters the search string. Now, as the user…
Pi.
  • 145
  • 1
  • 3
  • 7
8
votes
3 answers

notepad++ how to index files to search faster?

i was wondering if Notepad++ has a plugin or something to index the files so that the search will happen faster. I have a very large project and i am waiting 10 min for one search in code base. Any idea what might help me? thanks
Patrioticcow
  • 26,422
  • 75
  • 217
  • 337
8
votes
2 answers

How do I restrict search matches in Eclipse to filter out results in comments?

I want to search my whole project for a certain string, but I only want results which are uncommented. It would be great if there was just an option to not include comments in the search results, but I don't see how to do this. Is there a hidden…
Erick Robertson
  • 32,125
  • 13
  • 69
  • 98