Skip to content
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

field_value_factor should support a default value for documents that don't have the field #10841

Closed
nik9000 opened this issue Apr 27, 2015 · 3 comments · Fixed by #10845
Closed
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories

Comments

@nik9000
Copy link
Member

nik9000 commented Apr 27, 2015

I want to use field_value_factor to remove the last places we use dynamic scripting but I need to support default values if the field isn't set. I have unset fields because my load process is two stepped - I load all the documents first and then I run queries against the loaded set of documents to set the value of this field.

I could make sure to always set the value of the field but that seems brittle - I'd like to just default the field being missing to a 0 input to the field_value_factor function.

This looks pretty simple to implement and I'd be happy to do it if its something Elasticsearch wants.

@nik9000 nik9000 changed the title field_value_factor should support default a default value for documents that don't have the field field_value_factor should support a default value for documents that don't have the field Apr 27, 2015
@dakrone
Copy link
Member

dakrone commented Apr 27, 2015

+1 to this, would happily take a PR!

nik9000 added a commit to nik9000/elasticsearch that referenced this issue Apr 28, 2015
field_value_factor now takes a default that is used if the document doesn't
have a value for that field. It looks like:
"field_value_factor": {
  "field": "popularity",
  "default": 1
}

Closes elastic#10841
nik9000 added a commit to nik9000/elasticsearch that referenced this issue Apr 28, 2015
field_value_factor now takes a default that is used if the document doesn't
have a value for that field. It looks like:
"field_value_factor": {
  "field": "popularity",
  "missing": 1
}

Closes elastic#10841
dakrone pushed a commit that referenced this issue Apr 28, 2015
field_value_factor now takes a default that is used if the document doesn't
have a value for that field. It looks like:
"field_value_factor": {
  "field": "popularity",
  "missing": 1
}

Closes #10841

Conflicts:

	src/main/java/org/elasticsearch/common/lucene/search/function/FieldValueFactorFunction.java
@nik9000
Copy link
Member Author

nik9000 commented Apr 28, 2015

Thanks!

@dakrone
Copy link
Member

dakrone commented Apr 28, 2015

Thank you!

@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Query DSL labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants