Skip to content

Commit

Permalink
Merge pull request #17 from amymok/size-zip-issues
Browse files Browse the repository at this point in the history
issues with states and zip codes
  • Loading branch information
JeffreyMFarley authored Jul 21, 2017
2 parents 23aa99d + 1b69439 commit 671eec1
Show file tree
Hide file tree
Showing 24 changed files with 414 additions and 330 deletions.
28 changes: 14 additions & 14 deletions complaint_search/es_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _create_bool_should_clauses(self, es_field_name, value_list,

def _create_and_append_bool_should_clauses(self, es_field_name, value_list,
filter_list, with_subitems=False, es_subitem_field_name=None):

filter_clauses = self._create_bool_should_clauses(es_field_name, value_list,
with_subitems, es_subitem_field_name)

Expand Down Expand Up @@ -172,19 +172,19 @@ def build(self):
# All fields that need to have an aggregation entry
Field = namedtuple('Field', 'name size has_subfield')
fields = [
Field('has_narratives', 10, False),
Field('company', 10000, False),
Field('product', 10000, True),
Field('issue', 10000, True),
Field('state', 50, False),
Field('zip_code', 1000, False),
Field('timely', 10, False),
Field('company_response', 100, False),
Field('company_public_response', 100, False),
Field('consumer_disputed', 100, False),
Field('consumer_consent_provided', 100, False),
Field('tag', 100, False),
Field('submitted_via', 100, False)
Field('has_narratives', 0, False),
Field('company', 0, False),
Field('product', 0, True),
Field('issue', 0, True),
Field('state', 0, False),
Field('zip_code', 0, False),
Field('timely', 0, False),
Field('company_response', 0, False),
Field('company_public_response', 0, False),
Field('consumer_disputed', 0, False),
Field('consumer_consent_provided', 0, False),
Field('tag', 0, False),
Field('submitted_via', 0, False)
]

aggs = {}
Expand Down
2 changes: 1 addition & 1 deletion complaint_search/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class SearchInputSerializer(serializers.Serializer):
child=serializers.CharField(max_length=200), required=False)
state = serializers.ListField(
child=serializers.ChoiceField(STATE_CHOICES), required=False)
zipcode = serializers.ListField(
zip_code = serializers.ListField(
child=serializers.CharField(min_length=5, max_length=5), required=False)
timely = serializers.ListField(
child=serializers.CharField(max_length=200), required=False)
Expand Down
30 changes: 15 additions & 15 deletions complaint_search/tests/expected_results/search_no_param__valid.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"has_narratives": {
"terms": {
"field": "has_narratives",
"size": 10
"size": 0
}
}
}
Expand All @@ -57,7 +57,7 @@
"company": {
"terms": {
"field": "company",
"size": 10000
"size": 0
}
}
}
Expand All @@ -78,13 +78,13 @@
"product": {
"terms": {
"field": "product.raw",
"size": 10000
"size": 0
},
"aggs": {
"sub_product.raw": {
"terms": {
"field": "sub_product.raw",
"size": 10000
"size": 0
}
}
}
Expand All @@ -107,13 +107,13 @@
"issue": {
"terms": {
"field": "issue.raw",
"size": 10000
"size": 0
},
"aggs": {
"sub_issue.raw": {
"terms": {
"field": "sub_issue.raw",
"size": 10000
"size": 0
}
}
}
Expand All @@ -136,7 +136,7 @@
"state": {
"terms": {
"field": "state",
"size": 50
"size": 0
}
}
}
Expand All @@ -157,7 +157,7 @@
"zip_code": {
"terms": {
"field": "zip_code",
"size": 1000
"size": 0
}
}
}
Expand All @@ -178,7 +178,7 @@
"timely": {
"terms": {
"field": "timely",
"size": 10
"size": 0
}
}
}
Expand All @@ -199,7 +199,7 @@
"company_response": {
"terms": {
"field": "company_response",
"size": 100
"size": 0
}
}
}
Expand All @@ -220,7 +220,7 @@
"company_public_response": {
"terms": {
"field": "company_public_response.raw",
"size": 100
"size": 0
}
}
}
Expand All @@ -241,7 +241,7 @@
"consumer_disputed": {
"terms": {
"field": "consumer_disputed.raw",
"size": 100
"size": 0
}
}
}
Expand All @@ -262,7 +262,7 @@
"consumer_consent_provided": {
"terms": {
"field": "consumer_consent_provided.raw",
"size": 100
"size": 0
}
}
}
Expand All @@ -283,7 +283,7 @@
"tag": {
"terms": {
"field": "tag",
"size": 100
"size": 0
}
}
}
Expand All @@ -304,7 +304,7 @@
"submitted_via": {
"terms": {
"field": "submitted_via",
"size": 100
"size": 0
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"has_narratives": {
"terms": {
"field": "has_narratives",
"size": 10
"size": 0
}
}
}
Expand All @@ -78,7 +78,7 @@
"company": {
"terms": {
"field": "company",
"size": 10000
"size": 0
}
}
}
Expand Down Expand Up @@ -107,13 +107,13 @@
"product": {
"terms": {
"field": "product.raw",
"size": 10000
"size": 0
},
"aggs": {
"sub_product.raw": {
"terms": {
"field": "sub_product.raw",
"size": 10000
"size": 0
}
}
}
Expand Down Expand Up @@ -144,13 +144,13 @@
"issue": {
"terms": {
"field": "issue.raw",
"size": 10000
"size": 0
},
"aggs": {
"sub_issue.raw": {
"terms": {
"field": "sub_issue.raw",
"size": 10000
"size": 0
}
}
}
Expand Down Expand Up @@ -181,7 +181,7 @@
"state": {
"terms": {
"field": "state",
"size": 50
"size": 0
}
}
}
Expand Down Expand Up @@ -210,7 +210,7 @@
"zip_code": {
"terms": {
"field": "zip_code",
"size": 1000
"size": 0
}
}
}
Expand Down Expand Up @@ -239,7 +239,7 @@
"timely": {
"terms": {
"field": "timely",
"size": 10
"size": 0
}
}
}
Expand Down Expand Up @@ -268,7 +268,7 @@
"company_response": {
"terms": {
"field": "company_response",
"size": 100
"size": 0
}
}
}
Expand Down Expand Up @@ -297,7 +297,7 @@
"company_public_response": {
"terms": {
"field": "company_public_response.raw",
"size": 100
"size": 0
}
}
}
Expand Down Expand Up @@ -326,7 +326,7 @@
"consumer_disputed": {
"terms": {
"field": "consumer_disputed.raw",
"size": 100
"size": 0
}
}
}
Expand Down Expand Up @@ -355,7 +355,7 @@
"consumer_consent_provided": {
"terms": {
"field": "consumer_consent_provided.raw",
"size": 100
"size": 0
}
}
}
Expand Down Expand Up @@ -384,7 +384,7 @@
"tag": {
"terms": {
"field": "tag",
"size": 100
"size": 0
}
}
}
Expand Down Expand Up @@ -413,7 +413,7 @@
"submitted_via": {
"terms": {
"field": "submitted_via",
"size": 100
"size": 0
}
}
}
Expand Down
Loading

0 comments on commit 671eec1

Please sign in to comment.