Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4545874
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:52:27+00:00 2026-05-21T15:52:27+00:00

I’m trying to develop a way of taking an entity with a number of

  • 0

I’m trying to develop a way of taking an entity with a number of properties and searching for similar entities in the database (matching as many of the properties in the correct order as possible). The idea is that it would then return a % of how similar it is.

The order of the properties should also be taken into account, so the properties at the beginning are more important than the ones at the end.

For example:

Item 1 – A, B, C, D, E

Item 2 – A, B, C, D, E

Would be a 100% match

Item 1 – A, B, C, D, E

Item 2 – B, C, A, D, E

This wouldn’t be a perfect match as the properties are in a different order

Item 1 – A, B, C, D, E

Item 2 – F, G, H, I, A

Would be a low match as only one property is the same and it is in position 5

This algorithm will run for thousands and thousands of records so it needs to be high performing and efficient. Any thoughts as to how I could do this in PHP/MySQL in a fast and efficient manner?

I was considering levenshtein but as far as I can tell that would also look at the distance between two completely different words in terms of spelling. Doesn’t appear to be ideal for this scenario unless I’m just using it in the wrong way..

It might be that it could be done solely in MySQL, perhaps using a full text search or something.

This seems like a nice solution, though not designed for this scenario. Perhaps binary comparison could be used in some way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T15:52:28+00:00Added an answer on May 21, 2026 at 3:52 pm

    what i’d do is encode the order and property value into a number. numbers have the advantage of fast comparisons.

    this is a general idea and may still need some work but i hope it would help in some way.

    calculate a number (some form of hash) for each property and multiply the number representative of the order of appearance the property for an item.

    say item1 has 3 properties A, B and C.

    hash(A) = 123, hash(B) = 345, hash(C) = 456

    then multiply that by the order of appearance given that we have a know number of properties:

    (hash(A) * 1,000,00) + (hash(B) * 1,000) + (hash(C) * 1) = someval

    magnitude of the multiplier can be tweaked to reflect your data set. you’ll have to identify the hash function. soundex maybe?

    the problem is now reduced to a question of uniqueness due to hash collisions but we can be pretty sure about properties that don’t match.

    also, this would have the advantage of relative ease of checking if a property appears in another item in different order by using the magnitude of the multiplier to extract the hash value from the number generated.

    HTH.

    edit: example for checking matches

    given item1(a b c) and item2(a b c). the computed hash of items would be equal. this is a best case scenario. no further computations are required.

    given item1(a b c) and item2(d e a). computed hash of items are not equal. proceed to breaking down property hashes…

    say a hash table for properties a = 1, b = 2, c = 3, d = 4, e = 5 with 10^n for multiplier. computed hash for item1 is 123 and item2 is 451, break down the computed hash for each property and compare for all combinations of properties one for each item1 (which becomes item1(1 2 3) ) and item2 (which becomes item2(4 5 1) ). then compute the score.

    another way of looking at it would be comparing the properties one by one, except this time, you’re playing with numbers instead of the actual string values

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.