full text search - MySQL fulltext: have a result weigh more -


I have a database of cities and states (approximately 43,000) and I do a full text search on it: Select (against the City, State_Short, State) match (city, state_short, state) (select Q: in Boolean mode), where the number from Pincode (where city, state_short, state) is against (: Q in Boolean mode) Based on the city, state order score 6 by the score order

When I make a meaningful string to : q , work it But I say that I search for Houston Texas , I should be the first of the result, but instead it is the third:

  • Answer Houston, Texas
  • South Houston, Texas
  • Houston, Texas

    How do I Houston, Texas can weigh more than 2? This should be clearly similar to other such cities.

    Edit

    Does this work, any thoughts on this?

      from SELECT * (select city, state, matches (city, state_short, state)) (as in BOOLEAN MODE q) (Score: BOOLEAN in MODE) as zipcode by score (City, State_Short, State) Group according to the limit of DESC by city, state order 6) Order by DTH, Length (city) Post-text "itemprop =" text "> 

    Your new query may work, but it is completely circumstantial, instead of ORDER BY LENGTH (city) Something like this would be ORDER BY ABS (LENGTH (: q) - (LENGTH (city) + LENGTH (state)) This is not correct, but it should be better because the length of the input is equal and any higher point maybe what you are searching for. The last query will look something like this:

      Choose against city, state, match (city, state_short, state) (where in the boolean mode) scores from zipcode match (city, state_short , State) against the (: Q in Boolean mode) Group, by the City Order, DESC, ABS (LANGTH (Q) - (LENS (City) + LENS (STATE)) DISC limit 6   

    I remove the sub code in the new main code in the new ORDER BY section transfer The result will be the same (or possibly more accurate) results.

    Levenshatan distance is probably a more accurate solution for this, but there is no basic implementation of it in MySQL, a MySQL implementation of Levenshtein distance function There is more information about.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -