Hi all,
I am developing a search engine as project in PHP and MySQL as backend . I have implemented crawler , now i am facing problems in searcher . When a user enters any query by default i want to accept it as OR Query i.e. I want to display results containing all keywords in the beginning ( [assuming 4 keywords search] desc order of weight) then after that next results to be displayed would be links containing any of three keywords searched , same in desc order of weights and so on and so forth . till i don't display single keywords records ..
I am tired by thinking logic of this problem , for first displaying all keywords i have solved it but next problem i m unable to think .. can you give some ideas? please help!
mandy011
0
Light Poster
Recommended Answers
Jump to PostCan you perhaps give an example of what you have, and of what you want ?
If I understand correctly, you just want a way to order your results on relevancy.
Jump to PostIs it not possible to do an OR search with your query, let that calculate the weight in the result for each keyword, and then group it by article and summing the weight. Then you can order by the summed weight descending, without having to run X queries.
What …
Jump to PostYou should be able to do an OR search, and then GROUP BY link_id and SUM(weight).
SELECT link_id, SUM(weight) AS weight, domain FROM yourtables WHERE your keywords filter with OR instead of AND GROUP BY link_id
Perhaps you can try it in PhpMyAdmin (or another tool you …
Jump to PostYou get that because link_id appears in more tables. So in the SELECT and GROUP BY you need to specify which one you mean, just like you did with keyword_id in the WHERE.
Jump to PostNot sure what you mean. The GROUP BY will merge the results to one link_id, just as your DISTINCT did earlier, but it will SUM all the weights for that link_id.
All 25 Replies
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
mandy011
0
Light Poster
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
mandy011
0
Light Poster
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
mandy011
commented:
Thank you bro
+1
mandy011
0
Light Poster
mandy011
0
Light Poster
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
mandy011
0
Light Poster
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
mandy011
0
Light Poster
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
mandy011
0
Light Poster
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
mandy011
0
Light Poster
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
mandy011
0
Light Poster
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
mandy011
0
Light Poster
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
mandy011
0
Light Poster
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
mandy011
0
Light Poster
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
mandy011
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.