There is a set of records in the database (type of real estate, city, district, price, etc.), separated into several tables related to each other (real estate, addresses, (apartments, plots, etc.)). It is necessary to display records similar to the selected one (you can send it in the request as a whole, or its id (primary key)). It is desirable to assign weights to the fields, and based on comparing them with the template, add values ​​from zero to the field weight (100% match) to the records, and then sort the records from the most "heavy" to "light". Fields are text and numeric.

Is it possible to implement this task using SQL, and, if so, please tell me how or where to read more about it?

PS Records have a web-presentation (information page on a specific real estate option) with a permanent address of the format http://mysite.ru/info/id . Is it possible to use search engines (google, yandex, etc.) to find similar options? I found only an option with a simple addition of full-text search to the site, but perhaps there are more suitable tools?

  • Yes, you can decide. And how it depends on the specific task, the description, what is "similar" for each specific field separately. and the sql dialect is used, of course, the same depends. If the simple coincidence of the fields - then everything just multiplies the weight by the fact coincided or not. And for the difference in the texts, you can use full-text search or, for example, soundex - Mike
  • At the moment, for the price "it looks like" - this is + -200 000, for the rest - it coincided / did not coincide, but the requirements may change. But I’d like to see the query template, where and how to set the criteria for “like”, as well as the link, where to look for this. Google only LIKE and MATCH ( поле ) AGAINST ('search phrase') finds, without any explanation what, why, where and how - Dmitry Zorin
  • So you need to systematize the requirements. make for example a table of settings in which the allowable range is set (for numeric fields), which is by default from 0 to 0 - i.e. complete match. and weights in the same table can be. Of course for text fields everything is more complicated. here you really need to look at what match returns. And the structure of the database will have to be literally reduced to the key-value format in order to compare all sorts of parameters with a single query ... - Mike

0