Giter VIP home page Giter VIP logo

Comments (6)

lesters avatar lesters commented on April 28, 2024

This could probably be modelled by simply having follows as it's own document type with the fields: followee, follower and position. Then you can:

SELECT * FROM follows 
WHERE followee = "BigBob"
ORDER BY position;

from vespa.

schonfeld avatar schonfeld commented on April 28, 2024

@lesters do you mean, follows should be a struct data type with {followee, follower, and position} fields? I'm not sure I follow how that would work, considering array can't be indexed. Also, in your pseudo sql example above -- am I expecting to get back a list of profile IDs, or the actual profiles?

from vespa.

bratseth avatar bratseth commented on April 28, 2024

Yes, not much you can do with structs in Vespa other than storing and retrieving them.
You either need to do as Lester suggests, which gives you a lot of power at the expense of a higher document count, or

To retrieve all followers:
Add a new field followsHandle of type array which you can index and search.

To sort by follow time of the matching follower, you can either

Retrieve it from the "follows" array of struct in Java Searcher plugin (or in the client. This will be slow if you have a high number of followers.

or,

Add a
field handletimes type tensor(handle{})
to the document, where the value of each element is the add time, and pass a tensor(handle{}) in the query (say, query(follower)) with a single element {{handle:BigBob}:1}, and then rank by the ranking expression

sum(query(handles)*attribute(handletimes))

(i.e take the dot product).
This will work fine, but if the above is your one main use case it may be a bit complicated.

from vespa.

lesters avatar lesters commented on April 28, 2024

To elaborate on what I meant, by having follows as it's own document type, each edge in your social graph would be represented by a document. This allows some flexibility in maintaining the graph as well as the types of queries you can run (e.g. "who am I following" and "who is following me"). You could also attach additional information to the relationship if you needed that. Queries would return user id's. If you needed actual profile information you could retrieve that in a secondary query in a searcher (kind of like a fill) before returning to the user.

The downside is as Jon mentions a higher document count.

I guess this depends on the type of queries you would like to run?

from vespa.

schonfeld avatar schonfeld commented on April 28, 2024

Thanks for the pointers, guys.

Sounds like the best approach is in-fact a multiphase searcher. As I understand it, the searcher lives in the container cluster, and runs once (as opposed to living container, and running once for each bucket). I'm slightly worried about the memory footprint a searcher might need for a "supernode" query (e.g. a BarackObama type account with 50M followers). We'll try out various methods and report back to this thread later.

from vespa.

ddorian avatar ddorian commented on April 28, 2024

@schonfeld Still, if in 1 document, the BarackObama document will be huge!?
So you want to search only inside "follows" or you also want to search the top document "handle=Barack" ?

from vespa.

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.