-
-
Notifications
You must be signed in to change notification settings - Fork 989
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
[WIP] Allowed search results for Django code terms which contain stop words. #1942
Draft
sarahboyce
wants to merge
1
commit into
django:main
Choose a base branch
from
sarahboyce:stop-words
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
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
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,38 @@ | ||
# Instructions to create a new search dictionary | ||
|
||
In this folder, there is `custom_english.stop`. | ||
|
||
This copies the [snowball english stop words](https://github.com/postgres/postgres/blob/master/src/backend/snowball/stopwords/english.stop) | ||
but removes some stop words such as "through" and "when". This is because these | ||
terms are also used in Django code. | ||
|
||
The file format is a list of words, one per line. Blank lines and trailing | ||
spaces are ignored, and upper case is folded to lower case, but no other | ||
processing is done on the file contents. | ||
|
||
This file needs to be created in `$SHAREDIR/tsearch_data/custom_english.stop`, | ||
where `$SHAREDIR` means the PostgreSQL installation's shared-data directory, | ||
available via `pg_config --sharedir`. | ||
|
||
See https://www.postgresql.org/docs/current/textsearch-dictionaries.html | ||
|
||
Once the custom stop words file has been created, we can run the following SQL: | ||
|
||
```sql | ||
CREATE TEXT SEARCH DICTIONARY english_custom ( | ||
TEMPLATE = snowball, | ||
Language = english, | ||
StopWords = english_custom | ||
); | ||
|
||
CREATE TEXT SEARCH CONFIGURATION public.english_custom ( | ||
COPY = pg_catalog.english | ||
); | ||
|
||
ALTER TEXT SEARCH CONFIGURATION public.english_custom | ||
ALTER MAPPING | ||
FOR asciiword, asciihword, hword_asciipart, hword, hword_part, word | ||
WITH english_custom; | ||
``` | ||
|
||
This should then mean the `english_custom` search dictionary is available. |
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,119 @@ | ||
i | ||
me | ||
my | ||
myself | ||
we | ||
our | ||
ours | ||
ourselves | ||
you | ||
your | ||
yours | ||
yourself | ||
yourselves | ||
he | ||
him | ||
his | ||
himself | ||
she | ||
her | ||
hers | ||
herself | ||
it | ||
its | ||
itself | ||
they | ||
them | ||
their | ||
theirs | ||
themselves | ||
what | ||
which | ||
who | ||
whom | ||
this | ||
that | ||
these | ||
those | ||
am | ||
is | ||
are | ||
was | ||
were | ||
be | ||
been | ||
being | ||
have | ||
has | ||
had | ||
having | ||
do | ||
does | ||
did | ||
doing | ||
a | ||
an | ||
the | ||
and | ||
but | ||
or | ||
because | ||
as | ||
until | ||
while | ||
of | ||
at | ||
by | ||
about | ||
against | ||
between | ||
into | ||
during | ||
before | ||
after | ||
above | ||
below | ||
to | ||
from | ||
up | ||
down | ||
in | ||
out | ||
on | ||
off | ||
over | ||
under | ||
again | ||
further | ||
then | ||
once | ||
here | ||
there | ||
where | ||
why | ||
how | ||
any | ||
both | ||
each | ||
few | ||
more | ||
most | ||
other | ||
some | ||
such | ||
no | ||
nor | ||
not | ||
own | ||
same | ||
so | ||
than | ||
too | ||
very | ||
s | ||
t | ||
can | ||
will | ||
just | ||
don | ||
should |
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.
I have never done this before so these instructions may not be very good
I would love it if we can create this custom search dictionary in our docker setup as well
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.
Great job. Still few time to review properly, but I had two ideas: