B
B
Big_person2016-07-15 14:14:15
PHP
Big_person, 2016-07-15 14:14:15

How to search using Sphinx?

There is a database of cars. The task is to find from the table the most similar modification of the car by an arbitrary line.
I get the data for the index in sphinx.conf with the following request

SELECT car_modification.id_car_modification as id, 
      car_modification.name as modification, 
      car_serie.name as serie, 
      car_generation.name as generation, 
      car_generation.year_begin as year_begin, 
      car_generation.year_end as year_end, 
      car_model.name as model, 
      car_model.name_rus as model_rus, 
      car_mark.name as mark, 
      car_mark.name_rus as mark_rus 
      FROM car_modification 
      LEFT JOIN car_serie ON car_modification.id_car_serie=car_serie.id_car_serie 
      LEFT JOIN car_generation ON car_serie.id_car_generation=car_generation.id_car_generation 
      LEFT JOIN car_model ON car_generation.id_car_model=car_model.id_car_model 
      LEFT JOIN car_mark ON car_model.id_car_mark=car_mark.id_car_mark

Searching this way
$result = $cl->Query("Хундай санта фе 2008"); // поисковый запрос котрый выдает не верные результаты

1. How to make sphinx find results no matter what language the query is in?
2. How can you search up to the maximum nesting level brand-model-generation-series-modification.
That is, the query: "infiniti ex 37 2011" will return the modification id:
Brand - infiniti
Model - EX-Series
Generation - 1 generation [2007 - 2013]
Series - Crossover 5-door.
Modification - EX37 AT AWD (330 hp)
And the query "infiniti ex 2011" would return the generation id:
Brand - infiniti
Model - EX-Series
Generation - 1 generation [2007 - 2013]
3. How to make the year of manufacture of the car taken into account , which is specified in the query and specified in the series (range between year_begin, year_end)?
1 problem can be solved by using the php transcription function before executing the search query. But I guess it's a crutch.
Point 3 can be solved after we have received an array of results from sphinx, I re-sample and take into account the year of release, but it seems to me that this is again a crutch and this function should be performed by the search engine.
I can substitute the make, model and year separately in the search query using regular expressions for sampling.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Puma Thailand, 2016-07-15
@opium

1) none, translate on the php side
2) this logic will also have to be done in php
3) isolate the year in php and make a separate filter for it in
sphinx there is no magic it's just a search engine by text

K
ksnk, 2016-07-15
@ksnk

In the sphinx of magic, maybe not, but there are word forms.
search for words `shphinx wordforms` Dictionary
, however, will need to be compiled manually

кровать > bed
кресло > chair
красный > red
сумка > Bag
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question