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).

Filter by
Sorted by
Tagged with
3877votes
14answers
1.3mviews

grep a file, but show several surrounding lines?

I would like to grep for a string, but also show the preceding five lines and the following five lines as well as the matched line. How would I be able to do this?
user avatar
1868votes
16answers
567kviews

How to do case insensitive search in Vim

I'd like to search for an upper case word, for example COPYRIGHT in a file. I tried performing a search like: /copyright/i # Doesn't work but it doesn't work. I know that in Perl, if I give the ...
user avatar
867votes
22answers
753kviews

Use grep --exclude/--include syntax to not grep through certain files

I'm looking for the string foo= in text files in a directory tree. It's on a common Linux machine, I have bash shell: grep -ircl "foo=" * In the directories are also many binary files which ...
user avatar
765votes
14answers
375kviews

How can I combine two or more querysets in a Django view?

I am trying to build the search for a Django site I am building, and in that search, I am searching in three different models. And to get pagination on the search result list, I would like to use a ...
user avatar
  • 10.8k
759votes
12answers
268kviews

Solr vs. ElasticSearch [closed]

What are the core architectural differences between these technologies? Also, what use cases are generally more appropriate for each?
user avatar
  • 20.4k
732votes
9answers
208kviews

How to grep Git commit diffs or contents for a certain word

In a Git code repository I want to list all commits that contain a certain word. I tried this git log -p | grep --context=4 "word" but it does not necessarily give me back the filename (...
user avatar
713votes
38answers
120kviews

Generate an integer that is not among four billion given ones

I have been given this interview question: Given an input file with four billion integers, provide an algorithm to generate an integer which is not contained in the file. Assume you have 1 GB ...
657votes
23answers
888kviews

Python list of dictionaries search

Assume I have this: [ {"name": "Tom", "age": 10}, {"name": "Mark", "age": 5}, {"name": "Pam", "age": 7} ]...
user avatar
  • 56.6k
625votes
8answers
368kviews

What is the difference between re.search and re.match?

What is the difference between the search() and match() functions in the Python re module? I've read the documentation (current documentation), but I never seem to remember it. I keep having to look ...
user avatar
621votes
15answers
374kviews

Search all the occurrences of a string in the entire project in Android Studio

I've just started using Android Studio (IntelliJ), and I now look for the feature to find the occurrence of a string in any of the files in my project. For example: I want to find all the files that ...
user avatar
  • 43.9k
602votes
9answers
946kviews

How can I exclude one word with grep?

I need something like: grep ^"unwanted_word"XXXXXXXX
user avatar
  • 6,047
574votes
6answers
709kviews

Is there a short contains function for lists?

I see people are using any to gather another list to see if an item exists in a list, but is there a quick way to just do something like this? if list.contains(myItem): # do something
user avatar
  • 289k
530votes
7answers
466kviews

How to design RESTful search/filtering? [closed]

I'm currently designing and implementing a RESTful API in PHP. However, I have been unsuccessful implementing my initial design. GET /users # list of users GET /user/1 # get user with id 1 POST /user ...
user avatar
  • 38.1k
468votes
7answers
120kviews

How to find the Git commit that introduced a string in any branch?

I want to be able to find a certain string which was introduced in any commit in any branch, how can I do that? I found something (that I modified for Win32), but git whatchanged doesn't seem to be ...
user avatar
429votes
5answers
298kviews

Going to a specific line number using Less in Unix

I have a file that has around million lines. I need to go to line number 320123 to check the data. How do I do that?
user avatar
  • 4,514

15 30 50 per page
1
2 3 4 5
2394