drodil / backstage-plugin-qeta

Backstage.io plugin for Q&A
https://www.npmjs.com/package/@drodil/backstage-plugin-qeta
MIT License
86 stars 28 forks source link

Descriptive qeta search document #78

Closed cblnco closed 1 year ago

cblnco commented 1 year ago

There are a few values in the current qeta search document. I think it could be helpful to have a document that is a bit more descriptive so we can have more information available in the client side.

We could include a docType value to identify document type individually, author, answersCount and score. The result example of this document would look like this:

{
  "document": {
    "title": "Hello Ask",
    "text": "Hello this is a sample question",
    "location": "/qeta/questions/1",
    "docType": "qeta",
    "author": "user:default/user",
    "answers": 0,
    "score": 1
  }
}

In my team we take advantage of the docType value with Backstage's Search API to have buckets of documents by docType. This could be something that could be helpful for other customers when making queries with the search API.

In the client side this could be leveraged to show more details to users:

Screen Shot 2023-07-13 at 14 01 45

I would like to know your thoughts on this suggestion @drodil.

drodil commented 1 year ago

Makes sense. This needs a new type definition that extends the IndexableDocument. Are you willing to create a PR?

cblnco commented 1 year ago

Yes, I'm willing to. I was thinking that we can have a new interface like so:

export interface QetaDocument extends IndexableDocument {
  docType: string;
  author: string;
  score: number;
  answerCount?: number;
}

And then QetaCollatorFactory would return AsyncGenerator<QetaDocument>. What do you think @drodil?

cblnco commented 1 year ago

All right, thanks @drodil. I have made the following PR: #79 so we can close this Issue.