views:

222

answers:

1

i want to make my threads content searchable with full text search engines like solr.

but i wonder one thing. should i index just the thread.title, thread.body and post.body or should i index username, created date, nr of posts, views, country, region and city too that belongs to thread?

i mean when an user search for a thread he will get hits returned containing thread title, 2 lines of body, which user has posted it, creation date, tags, and so on.

should i index all this information too? but then it would be pretty much the whole database. or should i just index the 3 first columns i mentioned for full text search.

and another question. when an user post a new thread, then i have to immidiately tell solr to add that row? if im not, how would it be searchable?

+3  A: 

I have used Apache Lucene but I haven't used Apache Solr yet. So I'm extrapolating some of this answer. But Lucene indexing is what powers Solr so I assume it's pretty much the same.

I would add everything that you might want as part of the searchable content or returned as a result of a search.

Note that Lucene allows you to add fields to a document as "not analyzed" -- which means those fields aren't part of the searchable content. But the extra fields are returned when you do a search and it finds that document. The alternative is to include only the primary key and then you have to use that to do an SQL lookup after you have found matching documents.

Lucene also supports queries against specific fields in the index. So you could include all the fields in the index, but if you want a given search tomatch against only a subset of the fields, you can do that.

Finally, yes you have to keep the Lucene/Solr index in sync with the data in your database. You can use the DataImportHandler to help load batches of data from the RDBMS to the Solr server. Or you can use Solr's REST-like HTTP interface to post individual documents if you need them indexed in real time as new threads are created.

Bill Karwin
thx for answering so thoroughly. if i use sql so look up everything else then i have to run it in php. and then i cannot use only jquery and solr. i have to use jquery ajax to send variables to php, then php contact solr, get the information, and then do a sql lookup, then return it to jquery. it sounds like more coding than just to get the solr data through jquery directly. so i should probably index everything like u said and have the rest not searchable. what command do i use to send query string to and get data from solr with php??
weng
Since Solr has a REST interface, you could use PHP's curl extension to make the requests: http://php.net/curl
Bill Karwin