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 #671

Closed
peregilk opened this issue Nov 2, 2017 · 1 comment
Closed

field_value_factor #671

peregilk opened this issue Nov 2, 2017 · 1 comment

Comments

@peregilk
Copy link

peregilk commented Nov 2, 2017

Summary of problem or feature request

I am new to Elasticsearch. Ive been stuck for hours trying to figure out how to rank search results based on another search field.

In the example below, I am trying to search for product, but want the field "score" to affect the results. It is failing with "failed to create query".

I have tried using "random_score" (commented lines), and this works perfectly.

Code snippet of problem

#$randomScore = new \stdClass();
$params['body'] = array(
    'query' => array(
        'function_score' => array(
            'functions' => array(
                array("field_value_factor" => array('field' => 'score'))
                #array("random_score" => $randomScore)

            ),
            'query' => [
                'match' => [
                    'product' => 'shoe'
                ]
            ]
        )
    )
);

System details

Linux
Php 7.0
Elasticsearch 5.6.3
ES-PHP 5.0

@peregilk peregilk closed this as completed Nov 3, 2017
@peregilk
Copy link
Author

peregilk commented Nov 3, 2017

Fixed.The syntax above is correct. Turned out the product-field was set to string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant