-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search legislation TOC #1801
Merged
Merged
Search legislation TOC #1801
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ece67ef
WIP of indexing provisions for search
longhotsummer 13c7421
show provisions in search results
longhotsummer ec7c7bd
cards; padding; bug fixes
longhotsummer 8fa876d
also index num and type of provision
longhotsummer 6983e65
guard against duplicate provision results
longhotsummer 0af4ad4
add a data migration to add the new provisions field to the ES mapping
longhotsummer d90fc9e
adjust migration production check
longhotsummer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
peachjam/js/components/FindDocuments/SearchResultProvision.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<template> | ||
<div class="mb-1"> | ||
<div v-if="parents.length"> | ||
<a :href="`${expressionFrbrUri}#${parents[0].id}`">{{ parents[0].title }}</a> | ||
<div class="ms-3"> | ||
<SearchResultProvision | ||
:item="item" | ||
:parents="parents.slice(1)" | ||
:expression-frbr-uri="expressionFrbrUri" | ||
/> | ||
</div> | ||
</div> | ||
<div v-else> | ||
<a :href="`${expressionFrbrUri}#${item.id}`">{{ item.title }}</a> | ||
<div class="ms-3" v-if="item.highlight['provisions.body']" v-html="item.highlight['provisions.body'].join(' ... ')" /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'SearchResultProvision', | ||
props: { | ||
item: { type: Object, default: () => {} }, | ||
expressionFrbrUri: { type: String, default: '' }, | ||
parents: { type: Array, default: () => [] } | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import lxml.html | ||
|
||
html_parser = lxml.html.HTMLParser(encoding="utf-8") | ||
|
||
|
||
def parse_html_str(html): | ||
"""Encode HTML into utf-8 bytes and parse.""" | ||
return lxml.html.fromstring(html.encode("utf-8"), parser=html_parser) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
peachjam_search/migrations/0001_es_mapping_add_provisions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Generated by Django 3.2.25 on 2024-04-26 17:17 | ||
|
||
import os | ||
|
||
from django.db import migrations | ||
|
||
|
||
def forwards(apps, schema_editor): | ||
from django.conf import settings | ||
from django_elasticsearch_dsl.registries import registry | ||
|
||
if settings.ELASTICSEARCH_DSL_AUTOSYNC and os.environ.get("ELASTICSEARCH_HOST"): | ||
for ix in registry.get_indices(): | ||
if not ix._mapping: | ||
continue | ||
print(f"Adding provisions mapping for {ix._name}") | ||
ix.connection.indices.put_mapping( | ||
index=ix._name, | ||
body={ | ||
"properties": {"provisions": ix._mapping["provisions"].to_dict()} | ||
}, | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("peachjam", "0125_judgment_auto_assign_title"), | ||
] | ||
|
||
operations = [migrations.RunPython(forwards, migrations.RunPython.noop)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this allows us to add the new field to the mapping (which is allowed without having to destroy and re-create the mapping).
we only do it when DEBUG = False because we don't have an ES to talk to when testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neat