views:

26

answers:

4

in the match - against am getting the correct results, there is no problem but the thing i want is the result combination.

Like for "computer graphics" i am getting results for "+computer +graphics" as "computer" alone results and "computer graphics" results and "graphics" results and etc.

Here i want "computer graphics" results first then the other single word match results. How can i bring those first. Help me some one please

+1  A: 

This can't be done in MySQL fulltext search without a bit of hoop jumping.

You basically need to run the search twice to get your desired results. First, run a boolean fulltext search using double quotes to enclose the exact phrase being searched for. The double quotes in boolean mode will return exact matches only. Once you have those results, then your normal natural-language search. It's the normal, natural language search that is giving you trouble with partial matches. You'll need to manually combine the two search results.

While MySQL fulltext is decent for simple searching needs, it's not a great search solution. Consider something with more power, like Sphinx, Solr / Lucene, or even something like ElasticSearch.

Charles
+1  A: 

you should order by relevance: search for the same query you use in WHERE, call is RELEVANCE and then order by that field.

SELECT MATCH('...') AGAINST ('...') as Relevance FROM table WHERE MATCH('...') AGAINST('...' IN BOOLEAN MODE) ORDER BY Relevance DESC

Dario
+1  A: 

Assuming we're talking about a full-text index:

... ORDER BY MATCH('computer graphics') AGAINST (some,columns) DESC;
Wrikken
A: 

Entries in table

what is computer? what is graphics on computer? what is computer graphics? what is graphics?

QUERY : select *,MATCH(field1,field2) AGAINST ("+computer +graphics" IN BOOLEAN MODE) as results from $table where MATCH(field1,field2) AGAINST ("+computer +graphics" IN BOOLEAN MODE) ORDER BY results ASC

IT RETURNS exact results some where in the middle and others are first.

Like what is computer graphics? what is graphics on computer? what is computer? what is graphics?

How it can be corrected....

Ela