Skip to content

Commit

Permalink
Source/Collection | search by full_name and correcting other attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Apr 3, 2024
1 parent 8dc789f commit 7e9207a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
21 changes: 17 additions & 4 deletions core/collections/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,21 @@ class Django:

@staticmethod
def get_match_phrase_attrs():
return ['name', 'external_id', 'canonical_url']
return ['name', 'external_id', 'canonical_url', 'full_name']

@staticmethod
def get_exact_match_attrs():
return {
'id': {
'mnemonic': {
'boost': 4
},
'to_concept': {
'name': {
'boost': 3.5,
},
'from_concept': {
'full_name': {
'boost': 3.2,
},
'canonical_url': {
'boost': 3,
},
'external_id': {
Expand All @@ -78,6 +81,11 @@ def get_wildcard_search_attrs():
'lower': True,
'wildcard': True
},
'full_name': {
'boost': 0.6,
'lower': True,
'wildcard': True
},
'canonical_url': {
'boost': 0.6,
'lower': True,
Expand All @@ -93,6 +101,11 @@ def get_fuzzy_search_attrs():
'lower': True,
'wildcard': True
},
'full_name': {
'boost': 0.2,
'lower': True,
'wildcard': True
},
}

@staticmethod
Expand Down
17 changes: 16 additions & 1 deletion core/sources/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Django:

@staticmethod
def get_match_phrase_attrs():
return ['name', 'external_id', 'canonical_url']
return ['name', 'external_id', 'canonical_url', 'full_name']

@staticmethod
def get_exact_match_attrs():
Expand All @@ -63,6 +63,9 @@ def get_exact_match_attrs():
'name': {
'boost': 3.5,
},
'full_name': {
'boost': 3.2,
},
'canonical_url': {
'boost': 3,
},
Expand All @@ -84,6 +87,11 @@ def get_wildcard_search_attrs():
'lower': True,
'wildcard': True
},
'full_name': {
'boost': 0.6,
'lower': True,
'wildcard': True
},
'canonical_url': {
'boost': 0.6,
'lower': True,
Expand All @@ -96,6 +104,13 @@ def get_fuzzy_search_attrs():
return {
'name': {
'boost': 0.8,
'lower': True,
'wildcard': True
},
'full_name': {
'boost': 0.2,
'lower': True,
'wildcard': True
},
}

Expand Down

0 comments on commit 7e9207a

Please sign in to comment.