cofacts / rumors-db

Scripts for managing rumors db
https://g0v.hackmd.io/@mrorz/S1caurZq8
MIT License
6 stars 11 forks source link

Category labeling mechanism DB fields #37

Closed MrOrz closed 2 years ago

MrOrz commented 4 years ago

完成 Cofacts crowd-source label mechanism API(含 unit test、DB migration)

Related:

// articles
// (Remove "tags" field)

articles = {
  articleCategories: {
    type: 'nested',
    properties: {
      // Who connected the replyId with the article.
      // Empty if the category is added by AI
      userId: { type: 'keyword' },
      appId: { type: 'keyword' },

      // exists only for AI tags
      aiModel: {type: 'keyword'},
      aiConfidence: { type: 'double' },

      // Counter cache for feedbacks
      positiveFeedbackCount: { type: 'long' },
      negativeFeedbackCount: { type: 'long' },

      // Foreign key
      categoryId: { type: 'keyword' },

      status: { type: 'keyword' }, // NORMAL, DELETED
      createdAt: { type: 'date' },
      updatedAt: { type: 'date' },
    },
  },
}

articlecategoryfeedbacks = {
  // The article ID and reply ID is used in calculating replyrequests' ID.
  articleId: { type: 'keyword' },
  categoryId: { type: 'keyword' },

  // Auth
  userId: { type: 'keyword' },
  // The user submits the feedback with which client.
  // Should be one of backend APP ID, 'BOT_LEGACY', 'RUMORS_LINE_BOT' or 'WEBSITE'
  appId: { type: 'keyword' },

  score: { type: 'byte' }, // 1, -1
  comment: { type: 'text', analyzer: 'cjk_url_email' },   // user comment for the article category

  createdAt: { type: 'date' },
  updatedAt: { type: 'date' },
}

// categories
categories = {
  properties: {
    title: { type: 'text', analyzer: 'cjk' },
    description: { type: 'text', analyzer: 'cjk' },
    createdAt: { type: 'date' },
    updatedAt: { type: 'date' },
  }
};

Discussion: https://hackmd.io/SR5H5bYVRUGCYXF8ch7doQ

MrOrz commented 2 years ago

Fixed in https://github.com/cofacts/rumors-db/pull/38