I'm querying Solr like this:
http://XXX.xx.xx:xxx/solr/select?q=name:(pizza)&fq=locationid:6050 OR _query_:"{!bbox}"&sfield=location&pt=34.0211224, -118.39646&d=8
I am searching for records on name column and the record must fall on 8 kms Boundry OR locationid column value 6050.
Now I want to boost records which match locationid column value 6050.
If you use the locationid:6050 filter within the filter query parameter it won't influence the score. You should first of all move your filter inside the q parameter. Then you can use the edismax or dismax query parser and play around with the weight of your filter like this: locationid:6050^2. Have a look here.
Related
Im tring to understand the DSL query i needed if i want to make a search from a result set i got. means i have an initial term search, then i want make another query upon the previous result.
lets say i a have 10 documents with a sharing identifier between them, each document has a description field. i want to search first all the documents containing the value 'Hello' in the description and then take their id's, and search the document containing the value 'good by'.
thanks.
No need to execute two queries, you can use filter context that will filter out the results.filter parameter will filter out documents that do not match, and will also not affect the score for matching documents.
Filter context is in effect whenever a query clause is passed to a
filter parameter, such as the filter or must_not parameters in the
bool query, the filter parameter in the constant_score query, or the
filter aggregation.
Refer this to know more about Query and Filter contexts
I have multiple queries that need to filter data on elasticsearch. This queries are returning document ids from indexes that match the filter.
However i need to do another operation depending from user selection, to extract/add document unique id's from previous sum of queries with current query. The maximum number of query search is 5.
Is there an option in elastic so it will extract/add document id's from previous query? Right now i am doing this part in PHP with foreach iteration that takes a lot of time.
Edit
Example :
Ok let say we have one query on same index that contains :
{"query":{"bool":{"filter":[{"wildcard":{"182_empanalyzed":"example"}}]}}}
we will need to substract the document ids from the following query on same index :
{"query":{"bool":{"must_not":[{"nested":{"path":"184","query":{"exists":{"field":"184.*"}}}}]}}}
Keep in mind that this queries are example with only one condition in it, there might be more complexes queries with many fields to be searched on in each query. And from each following query there is an option to substract/add documents ids
Is it possible to give fix score based on every field match. for e.g one field matched then increment score for document by 1 , second field matched then increment document score by 1, so if there are one fields matched the score would be 1 if two fields matched then score would be 2 and so on...
The best tool for modifying the _score value of a query is the function_score query.
Elasticsearch actually offers many methods for calculating the score for each match. You can use a custom_score query along with a script to access the value of a particular numeric field. Consider this statement:
"script" : "_score * doc['my_numeric_field'].value"
Here, we are giving weight to the value of my_numeric_field by multiplying it with the default _score. You could also use the custom_filters_score_query, in which you apply filters to restrict the result set and then use a script or a boost to assign a score to any documents that match the filter. Similarly, you could apply the custom_boost_factor to any query to multiply the default score of that query with a boost value. In the 0.19.0 release of Elasticsearch, there is a new query that combines all of these into the function_score query.
I have a few records in my elasticsearch collection and i want to use a GroupBy aggregation in elasticsearch querystring.
I want to know if it is possible, because i tried to google it always give result about this
i want to use this something like this in the query string , which can
give me records in the group.
For i.e.
http://localhost:9200/_all/tweets/_count?q=user:Pu*+user:Kim*
This will give me count of all the records which has name starts from Pu and Kim,
But i want to know that how many records are there has name starting with Pu
and Kim,
aggregations need to be specified in addition in the search request, you cannot specify them as part of a query string query.
You could also just execute two queries to find out this particular requirement...
Is it possible to retrieve Stats Aggregation with custom field value of max/min document?
Eg. imagine example from ElasticSearch Stats Aggregation documentation is there possible to retrieve for example name of student with max/min value of grade? (we assume that beside grade there is student name in document).
Is it even possible? What if ElasticSearch gives us multiple documents with max/min value?
No - it's not possible to get a max value and the rest of the document in a single query.
You would need to do two queries - the first to get the max value, the second to return documents that have a matching value.