Answer the question
In order to leave comments, you need to log in
How to implement a search algorithm by first and/or last name?
Good day.
Interested in the idea of implementing a search algorithm for a social network (php: zf). At first I planned to use Lucene, now I'm looking towards Sphinx.
The database (mysql) now has ~250,000 users. First name and last name are stored in different fields of the table.
Task : It is necessary to find a person by name and / or surname. For example, Ivanov Sidor. Moreover, in the results, I would like to see people "Ivanov Sidor" or "Sidor Ivanov", results like "Ivanov Petr" and "Ivanov Pupkin" should not be.
Later, you may need to add a nickname search as well.
It is also worth considering that the search can be conducted both only by last name, and only by first name.
Also, the first and/or last name can consist of several words, for example "
The main focus is on speed and performance.
I would like to get more information about the implementation: links, articles, opinions, personal experience - everything will fit, I will be very grateful.
Answer the question
In order to leave comments, you need to log in
For me, storing names and surnames can be done in the form of dictionaries. There are no word forms.
Yes, this is directly a pattern for the sphinx. No special tricks or transformations are required. Directly and index - a name in one field, a surname in another. The query "Vasya pupkin" will return what you want; in addition, you can do a selective search like "@name Vasya" - only by the "name" field.
Add a nickname in the same way (just add a column to the rowset output when indexing; and if there is some select *, then you don’t even need to touch the sphinx config; add a column in the table, and then reindex and everything will be picked up)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question