Welcome Guest, Not a member yet? Register   Sign In
Need help with search engine
#11

[eluser]sobencha[/eluser]
While not related to the MySQL full text search, I thought I'd throw out one alternative that you might want to pursue depending upon how "heavy-duty" a search you are hoping to implement.

For full-text search, I always tend to use Apache Lucene rather than any DB specific implementation. Specifically in MySQL, as you are reliant upon the MyISAM table type, and I often utilise the InnoDB type.

I find it very powerful and development with it is very [I think] intuitive. You can easily index a huge number documents (xml, html, rtf, doc, etc.) as well as database entries. From my experience, performance of both the indexing routines and the actual search itself have been very fast.

The original and as far as I know best implementation is in Java, and that's the one that I have the most experience with, but the Zend framework provides a PHP port of the library. It's a shame that Zend is the only PHP port [that I know of], but so it goes. I have used this port in a couple of CodeIgniter applications now. Also, the indexes that are created should be interoperable between any Lucene implementation (PHP, Java, Python, .net, etc.).

Zend port -> http://framework.zend.com/manual/en/zend...ucene.html
Java -> http://lucene.apache.org/java/docs/
#12

[eluser]M4rc0[/eluser]
Thanks guys, i finally did it.
This topic is very informative.

Following Randy advice to do my own spaghetti, i did the way things worked for me here.
So if anybody else hits this topic:

Model
Code:
function search_movie()
     {    
        $keywords = "'".$this->input->post('keywords')."'";        
        $query = $this->db->query('SELECT * FROM movies WHERE MATCH (name,opinion) AGAINST ('.$keywords.' WITH QUERY EXPANSION);');
    
        return $query->result();    
     }

View
Code:
<ul id="movies">
&lt;?php foreach($query as $movie):?&gt;
    <li><a >id;?&gt;" title="&lt;?=$movie->name;?&gt;"><img class="tip">cover_thumb;?&gt;" title="&lt;?=$movie->name;?&gt;" /></a></li>
&lt;?php endforeach;?&gt;
</ul>

If one day i make a larger application, I'll consider the other options of this topic.

Just a question, is it true that using FULLTEXT for small-medium database can be slow?

EDIT: I realize that if i don't type the name correctly or the fullname, it won't return any results.
For instance: the name is "terror" if i type "ter" or "terrorrs" it will return empty.
Better than using %like% though.
But is there anything extra to add in the query to make that possible?

Thanks!
#13

[eluser]Randy Casburn[/eluser]
You'll want to do some research on heuristics or heuristic searching criteria or inference rules.

Randy
#14

[eluser]M4rc0[/eluser]
[quote author="Randy Casburn" date="1222632492"]You'll want to do some research on heuristics or heuristic searching criteria or inference rules.

Randy[/quote]

:ohh:

I tried in a simpler way:
Code:
$query = $this->db->query('SELECT * FROM movies WHERE name LIKE %'.$keywords.'% OR MATCH (name,opinion) AGAINST ('.$keywords.' WITH QUERY EXPANSION);');

Using the LIKE for the name (title) only. But still returning none if I typo.

Well, I have what I needed and i think this code is useful to stay in the forum anyway.

The best solution will be using google custom search for later i guess.

Thank you all for the discussion! (:
#15

[eluser]Randy Casburn[/eluser]
OK...quite innovative. I thought you were going to search through the entire script or something quite insane.

Good job! Simple is always better.

Randy




Theme © iAndrew 2016 - Forum software by © MyBB