Skip to content
This repository has been archived by the owner on Jul 25, 2018. It is now read-only.

API for Relationships widget #33

Open
lustoykov opened this issue Mar 28, 2017 · 15 comments
Open

API for Relationships widget #33

lustoykov opened this issue Mar 28, 2017 · 15 comments

Comments

@lustoykov
Copy link

lustoykov commented Mar 28, 2017

See MusicConnectionMachine/RelationshipsG3#27

I don't have rights, so please add Assigness and Deadline: 02.04.2017

so yesterdey me, @martomi and @vviro had a meeting and here is what came out of the discussion

The basic idea is that we want to display in a somewhat-table view non-trivial relationships (almost like a surprise-fun-fact table - Mozart | Liked | Getting Drunk)

Entity | Relation | Entity

When a user on the IMSLP site and exploring our widget, one of the entities is always fixed (for instance Mozart).

Now we want to have a search bar, where user can type in. The search bar should be very smart and display autosuggestions in form of:

Relations Suggestions

  • Entity1
  • Entity2
    ...

Entities Suggestions

  • Entity1
  • Entity2
    ...

Whenever a user clicks one of the suggestions, we'd make an api call with Entity | Entity expecting relations as response or Entity | Relations expecting entities as response to display the table view Entity | Relation | Entity

Requirement: for the autosuggestions

  • the API GET /autosuggest should accept:
    a single param query: { primaryEntity, searchInput, }

  • the API should deliver:

{ 
   entitites: [ { title: '...', importance: '...', confidence: '...' }, { ... } ]
   relations: [ { title: '...', importance: '...', confidence: '...' }, { ... } ]
}

at least title is required, importance and confidence would be nice.


Requirement: for data display

  • The API GET /relations should accept:
    a single param query: { primaryEntity: String, secondaryEntity: String, }

and return

{ 
   relations: [ { title: '...', importance: '...', confidence: '...' }, { ... } ]
}
  • The API /entities should accept:
    a single param query: { primaryEntity: String, relation: String, }

and return

{ 
   entities: [ { title: '...', importance: '...', confidence: '...' }, { ... } ]
}

@martomi can you double check if the API as defined is OK? Please edit the post directly if I missed something.

@vviro also encourages us to talk to him more often.

@lustoykov
Copy link
Author

lustoykov commented Mar 28, 2017

@kordianbruck just for final confirmation - is elasticsearch / API in scope of the visualization group?
Because @Henni is asking good questions regarding design of the API? I had the impression they provide the API? Can we clarify this asap so we can collaborate more efficiently?

@lustoykov
Copy link
Author

lustoykov commented Mar 28, 2017

@Henni the query we're sending won't be an id, but a plain text from the search bar, I think subject_id might be misleading as name. Maybe subject and object is better?

Yes, so, if object couldn't be Getting Drunk, but only musicians, composers and pieces - that's OK. I only described ideal world, but you decide what to give as response (or what to save in the DB)

@kordianbruck
Copy link
Contributor

kordianbruck commented Mar 28, 2017

@lustoykov we are not doing elastic at all. Instead you guys are going to utilize PostregreSQL Fulltext search capabilities by implementing the search api (which is then basically almost the same as the autocomplete endpoint)

@lustoykov
Copy link
Author

lustoykov commented Mar 28, 2017

OK then, so

  • G3 / G4 provide database with entities / relation tables as described. G3 / G4 can you link your DB structure or describe it here?
  • G5 implements the APIs and visualises the data as described

Is that the agreement?

@martomi
Copy link
Contributor

martomi commented Mar 28, 2017

Question regarding the GET /autosuggest endpoint:

Don't we need two parameters there? One is the primaryEntity and the other one the current input from the search field?

Also I think confidence and importance are not independent attributes in our context, one of them should be sufficient.

@lustoykov
Copy link
Author

lustoykov commented Mar 28, 2017

importance means how important the relation is (we want to display top 5 probably), confidence means how likely it is to be accurate? I agree on GET /autosuggest, edited my post.

@martomi
Copy link
Contributor

martomi commented Mar 28, 2017

Yes, I understand their meaning, but both of them are calculated from the number of occurrences of the said relations in the data we have. This makes them dependent on one another.

Unless we use another metric for the confidence such as tracking user feedback on said relations. In that case you might go with something simpler such as a field that contains an integer with the number of times the relation has been flagged by someone.

@Henni
Copy link
Contributor

Henni commented Mar 28, 2017

@lustoykov db schemata are currently discussed over here #28

@martomi
Copy link
Contributor

martomi commented Mar 31, 2017

@lustoykov GET /autosuggest would make more sense to deliver the following format in my opinion, but it's almost the same:

{ 
   entitites: {
        artists: [
            { id, name, artist_type, picture, dateOfBirth, placeOfBirth, dateOfDeath, nationality, tags, pseudonym, source_link }
            ...
        ],
        instruments: [
            {id, name }
            ...
        ],
        releases: [
            { id, title, format, date, country, label }
            ...
        ]
   }
   relations: [ 
         { title: '...', confidence: '...' }
          ... 
   ]
}

@lustoykov
Copy link
Author

lustoykov commented Mar 31, 2017

I don't mind, will adjust the frontend once the final API is there. Then the relations should be nested as well, because otherwise if I'd want to access the 3rd relation for instruments I'd need the count of artists.

@martomi
Copy link
Contributor

martomi commented Mar 31, 2017

@lustoykov What is the use case of that?

@lustoykov
Copy link
Author

it is just more consistent design in my opinion, the split in entities and non-split in relations seems a bit arbitrary to me. anyways, I don't mind here much - whatever you prefer.

@martomi
Copy link
Contributor

martomi commented Mar 31, 2017

Entities have different types and underlying models hence the need for a split.

If you prefer a more consistent look, an alternative structure would be to drop entities altogether.

{ 
   artists: [
        { id, name, artist_type, picture, dateOfBirth, placeOfBirth, dateOfDeath, nationality, tags, pseudonym, source_link }
        ...
   ],
   instruments: [
        {id, name }
         ...
   ],
   releases: [
        { id, title, format, date, country, label }
         ...
    ]
   relations: [ 
         { title: '...', confidence: '...' }
          ... 
   ]
}

Those correspond to actual models in the backend.

@lustoykov
Copy link
Author

no worries, do whatever you feel like is best, just let me know when it is final so I can adjust the frontend.

@kordianbruck kordianbruck changed the title Widget to explore Relationships - Requirements API for Relationships widget Apr 17, 2017
@kordianbruck kordianbruck added this to the 21.04 - Pre Hackathon milestone Apr 17, 2017
Henni pushed a commit that referenced this issue Apr 23, 2017
* Add the API implementation for the relationship widget (#33).

* Minor code refactoring

* implement subject mapper functions
@lustoykov
Copy link
Author

lustoykov commented Apr 24, 2017

What's the status here? Can you ping me in MusicConnectionMachine/VisualizationG5#80 when done?

Thanks

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

No branches or pull requests

5 participants