Questions about SOLR documents and a few more

Website: Website for ads (users can advertise, search ads, etc.)

I plan to use SOLR to search, and then return the results only as ID nr: s, and then use those IDs nr: s and query mysql, and then finally display the results with these IDs: s.

I currently have about 30 tables in MySQL, one for each category.

1 Do you think I should do it differently than the higher?

2- Should I use only one SOLR document or several documents? Also, is the document the same as the SOLR index?

3. Would it be better to use SOLR and skip MySQL, knowing that I have many columns in each table? Personally, I use MySQL much better than SOLR.

4 Say that the user wants to search for cars in a specific region, how is this query executed in SOLR? Example: q=cars®ion=washington maybe?

You might think that there is a lot of information about SOLR, but not, and especially not about using PHP with SOLR and the SOLR-php client ... Maybe I will write something when I find out all this ... Or, maybe perhaps one of you could write something!

Thanks again for your help ...

+3
source share
4 answers

First, definitions: a Solr / Lucene document is roughly equivalent to a database row. The index is approximately the same as the database index.

I recommend storing all sensitive information in Solr. Querying Solr and then the database is inefficient and most likely not needed.

A query in a specific area will be something like q=cars+region:washington if you have a region field in Solr.

The solr wiki contains a ton of useful information and a pretty good basic tutorial . Of course, this can always be improved, so if you find something incomprehensible, let the Solr team know about it.

I can not comment on the PHP client, since I do not use PHP.

+7
source

Solr is about to return it, resulting in syntax that is easy to understand with SimpleXml. You can also use the SolPHP client library: http://wiki.apache.org/solr/SolPHP .

Solr is really quite effective. I suggest putting as much data into your Solr index as you need to get all in one beat from Solr. This could mean a lot less database traffic for you.

If you installed the Solr sample application (shipped with Jetty), you can develop Solr queries using the admin interface. The result URI is pretty much what you build in PHP.

The hardest part starting with Solr is the correct solrconfig.xml and schema.xml files. I suggest starting with a very simple configuration and restarting the web application every time you add a field. Getting started with all schema.xml can be confusing.

0
source

2- Should I use only one SOLR document or several documents? Also, is the document the same as the SOLR index?

3- Would it be better to use SOLR and skip MySQL, knowing that I have many columns in each table? Personally, I use MySQL much better than SOLR.

The document is an "instance" of the solr index. Note that you can only build one solr index per processor. The kernel acts as an independent solr server in the same merge.

http://wiki.apache.org/solr/CoreAdmin

Yo can create one index combining some table contents and some other indexes to perform a second level search ...

Could you tell us more about your architecture and data?

0
source

As suggested by others, you can store and index your mysql data and run the query in the solr index, thereby making mysql unnecessary. You do not just need to store and index identifiers and query and receive identifiers, and then run a mysql query to get additional data against this identifier. You can simply save other data corresponding to the identifiers in the solr itself.

As for the solr PHP client, you do not need to use it, so it is recommended to use REST, for example, the Solr Web API. You can use a PHP function, for example file_get_contents("http://IP:port/solr/#/core/select?q=query&start=0&rows=100&wt=json") , or use curl with PHP if you need to. Both methods are almost identical and effective. This will return the data in json as wt=json . Then use the PHP function json_decode($returned_data) to get this data in the object.

If you need to ask something, just answer.

0
source

Source: https://habr.com/ru/post/1302600/


All Articles