Coder Social home page Coder Social logo

Is there a score per result? about tntsearch HOT 3 CLOSED

teamtnt avatar teamtnt commented on September 15, 2024 1
Is there a score per result?

from tntsearch.

Comments (3)

fishgrind avatar fishgrind commented on September 15, 2024 2

@t2thec

there are some fields in the database that show this will be added. see answer here: #56

for now you could use the php similar_text function to add a weighting to the results array..

something like this:

foreach ($res['ids'] as $result) {

//fetch data for id from database here.

similar_text(strtolower($yourSearchQuery), strtolower($resultArray['arrayKeyToSort']), $percent);

//push data to array and include the $percent
}

After this you can sort the array using usort

from tntsearch.

t2thec avatar t2thec commented on September 15, 2024

Sweet. Thanks @fishgrind. Legendary work!

from tntsearch.

fishgrind avatar fishgrind commented on September 15, 2024

@t2thec no worries. Just remember similar_text is case sensitive hence the strtolower()

probably better and faster is using levenshtein() though see http://www.w3schools.com/php/func_string_levenshtein.asp

from tntsearch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.