-
-
Notifications
You must be signed in to change notification settings - Fork 164
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
Adding address unit attribute to api output and queries #1052
Open
sweco-semhul
wants to merge
6
commits into
pelias:master
Choose a base branch
from
sweco-semhul:adding-address-unit
base: master
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.
Open
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a832292
Adding unit attribute for addresses in api output
sweco-semhul 9d1c507
Adding unit attribute for addresses in api search
sweco-semhul 761c295
Adding dependencies for model, query and analyzer to adding-address-u…
sweco-semhul 6b8c9f6
Switching unit attribute to always be last also for standard and chan…
sweco-semhul c7b5baf
Merge branch 'master' into adding-address-unit
66a458f
Moving libpostal unit configuration into updated logic
sweco-semhul 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
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
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
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
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
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
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
161 changes: 161 additions & 0 deletions
161
test/unit/fixture/search_full_address_original_with_unit.js
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,161 @@ | ||
var vs = require('../../../query/search_defaults'); | ||
|
||
module.exports = { | ||
'query': { | ||
'bool': { | ||
'must': [ | ||
{ | ||
'match': { | ||
'name.default': { | ||
'analyzer': 'peliasQueryFullToken', | ||
'boost': 1, | ||
'query': '431 St Kilda Rd' | ||
} | ||
} | ||
} | ||
], | ||
'should': [ | ||
{ | ||
'match': { | ||
'phrase.default': { | ||
'analyzer': 'peliasPhrase', | ||
'type': 'phrase', | ||
'boost': 1, | ||
'slop': 2, | ||
'query': '431 St Kilda Rd' | ||
} | ||
} | ||
}, | ||
{ | ||
'function_score': { | ||
'query': { | ||
'match': { | ||
'phrase.default': { | ||
'analyzer': 'peliasPhrase', | ||
'type': 'phrase', | ||
'boost': 1, | ||
'slop': 2, | ||
'query': '431 St Kilda Rd' | ||
} | ||
} | ||
}, | ||
'max_boost': 20, | ||
'functions': [ | ||
{ | ||
'field_value_factor': { | ||
'modifier': 'log1p', | ||
'field': 'popularity', | ||
'missing': 1 | ||
}, | ||
'weight': 1 | ||
} | ||
], | ||
'score_mode': 'first', | ||
'boost_mode': 'replace' | ||
} | ||
}, | ||
{ | ||
'function_score': { | ||
'query': { | ||
'match': { | ||
'phrase.default': { | ||
'analyzer': 'peliasPhrase', | ||
'type': 'phrase', | ||
'boost': 1, | ||
'slop': 2, | ||
'query': '431 St Kilda Rd' | ||
} | ||
} | ||
}, | ||
'max_boost': 20, | ||
'functions': [ | ||
{ | ||
'field_value_factor': { | ||
'modifier': 'log1p', | ||
'field': 'population', | ||
'missing': 1 | ||
}, | ||
'weight': 2 | ||
} | ||
], | ||
'score_mode': 'first', | ||
'boost_mode': 'replace' | ||
} | ||
}, | ||
{ | ||
'match': { | ||
'address_parts.unit': { | ||
'analyzer': vs['address:unit:analyzer'], | ||
'boost': vs['address:unit:boost'], | ||
'query': '8' | ||
} | ||
} | ||
}, | ||
{ | ||
'match': { | ||
'address_parts.number': { | ||
'analyzer': vs['address:housenumber:analyzer'], | ||
'boost': vs['address:housenumber:boost'], | ||
'query': '431' | ||
} | ||
} | ||
}, | ||
{ | ||
'match': { | ||
'address_parts.street': { | ||
'analyzer': vs['address:street:analyzer'], | ||
'boost': vs['address:street:boost'], | ||
'query': 'St Kilda Rd' | ||
} | ||
} | ||
}, | ||
{ | ||
'match': { | ||
'parent.region_a': { | ||
'analyzer': vs['admin:region_a:analyzer'], | ||
'boost': vs['admin:region_a:boost'], | ||
'query': 'Melbourne' | ||
} | ||
} | ||
}, | ||
{ | ||
'multi_match': { | ||
'fields': [ | ||
'parent.country^1', | ||
'parent.region^1', | ||
'parent.county^1', | ||
'parent.localadmin^1', | ||
'parent.locality^1', | ||
'parent.borough^1', | ||
'parent.neighbourhood^1', | ||
'parent.region_a^1' | ||
], | ||
'query': 'Melbourne', | ||
'analyzer': 'peliasAdmin' | ||
} | ||
} | ||
], | ||
'filter': [ | ||
{ | ||
'terms': { | ||
'layer': [ | ||
'address', | ||
'venue', | ||
'country', | ||
'region', | ||
'county', | ||
'neighbourhood', | ||
'locality', | ||
'localadmin' | ||
] | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
'size': 10, | ||
'track_scores': true, | ||
'sort': [ | ||
'_score' | ||
] | ||
}; |
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.
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 line should be changed so that the unit is last. Also, the string concatenation approach is getting a bit messy here. It would be great if you updated the code to use Array.join. It can handle putting in appropriate whitespace pretty nicely
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.
Thanks for the clarification!
Yeah I agree on that. Will change the order and get it a bit less messy 😃