dreamproit / billtitles-py

Service to get bills, titles and bills related by title (using FastAPI); see also billtitles in Go
MIT License
1 stars 1 forks source link

Update API to return incorporated bills: A to B and B to A #18

Open aih opened 2 years ago

aih commented 2 years ago

When a small bill (B) is incorporated in a large one (A), it is likely that the ES queries for B will return A as a similar bill, but not B as a similar bill to A.

In order to handle this, we can create the list of similar bills in the API by combining them in the SQL query. Perhaps we only add this sql query for large bills, or upon a user request?

[Alternately, when we find a small bill with a relationship to a large one as a result in ES query, we can store the A to B relationship.]

aih commented 2 years ago

Example, 117hr1767 is a small bill related to 117hr4350. When searching for 117hr4350 currently, 117hr1767 does not appear in the list. However, when searching for 117hr1767, the larget bill does appear:

 {
    "billnumber_to": "117hr4350",
    "version_to": "rh",
    "length_to": 6795860,
    "billnumber": "117hr1767",
    "version": "ih",
    "length": 4697,
    "score": null,
    "score_to": null,
    "reasonsstring": "",
    "sections_num": 2,
    "sections_match": 1,
    "score_es": 95.86207,
    "bill_id": 32716,
    "bill_to_id": 3018,
    "billnumber_version": "117hr1767ih",
    "billnumber_version_to": "117hr4350rh",
    "reasons": [
      ""
      ]...
aih commented 2 years ago

In another example, only the rh version of 1174350 is found to be similar in the ES search:

 {
    "billnumber_to": "117hr4350",
    "version_to": "rh",
    "length_to": 6795860,
    "billnumber": "117hr2059",
    "version": "ih",
    "length": 4093,
    "score": null,
    "score_to": null,
    "reasonsstring": "",
    "sections_num": 2,
    "sections_match": 1,
    "score_es": 62.86768,
    "bill_id": 23161,
    "bill_to_id": 3018,
    "billnumber_version": "117hr2059ih",
    "billnumber_version_to": "117hr4350rh",
...