Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order by relevance #127

Closed
drewdeakin opened this issue Feb 1, 2018 · 3 comments
Closed

Order by relevance #127

drewdeakin opened this issue Feb 1, 2018 · 3 comments

Comments

@drewdeakin
Copy link

Is it possible to order the results by relevance?

Single word searches are okay, (ie searching for "balance", brings up any thing with "balance")

But when you start using 2 or more words (ie "balance naturals"), I'm getting results with either "balance", "naturals" and "balance naturals".

The code I am using is below;

$tnt->selectIndex( "products.index" );
$tnt->asYouType = true;

$res = $tnt->search( $_GET['query'], 120 );
$res = implode( ',', $res['ids'] );
@stokic
Copy link
Contributor

stokic commented Feb 1, 2018

The whole point of the full-text search is that the results are already ranked by relevance. Otherwise, it wouldn't make much sense, would it? :)

What you need is Boolean search https://github.com/teamtnt/tntsearch#boolean-search

@renanvalente
Copy link

renanvalente commented Feb 16, 2018

And if I want to change relevance, add new criteria.
Example:
Order also by date.

Is it possible?

@nticaric
Copy link
Contributor

@renanvalente TNTSearch returns a list of ids containing your search query. What you can do is
to add an oder criterion in your query. ie date

SELECT * FROM articles WHERE id IN $res ORDER BY date;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants