How to rename the query response field name just like mysql's select as query in Elasticsearch?
Note this is on the query not influence the index process which is different from this question
Related
can anyone help me to translate below SQL query to ELasticSearch DSL form for document selections?
SELECT * FROM table1 WHERE source_id IN (select source_id FROM table2)
This JOIN semantics does not translate to Elasticsearch. If your index had parent/child mapping - you might be able to achieve what you want to do. Another option is to do a two-pass query.
This blog post gives an idea of how relations are modeled in Elasticsearch - Managing Relations in Elasticsearch
Lets say I have a query like
Select * from table
Group By field_1, field_2, field_3
Order By filed_7;
How to achieve the same functionality in elasticsearch.
I use Composite Aggregations to do Group by multiple fields. Is it possible to do the sorting part?
Is there a way to rename the output fields from an elasticsearch query (like the "select .. AS .." in SQL)? I want to keep the original names of the fields in the index, and only modify their names in the result of the query.
I've read this but it says to re-index the data.
This isn't currently possible in Elasticsearch. If you need this kind of transformation, you'll need to do it application-side.
Can you nest queries logically in ElasticSearch, so the output of one query is the input to another query.
Another, way to ask is how can I chain or pipe queries together?
This should be analogous to the IN operator or subqueries in SQL
i.e.:-
select au_lname, au_fname, title from
(select au_lname, au_fname, au_id from pubs.dbo.authors
where state = 'CA')
or
SELECT Name
FROM AdventureWorks2008R2.Production.Product
WHERE ListPrice =
(SELECT ListPrice
FROM AdventureWorks2008R2.Production.Product
WHERE Name = 'Chainring Bolts' );
Elasticsearch doesn't support subqueries; you would need to perform your first query, then construct a second query using the results of the first query as an input.
this is not supported in elastic-search you must normalize your data and have all field you need in one setting
That is totally correct, you must programm a subquery in your favorite programming language. An example can be found here:
https://sebastianviereck.de/elasticsearch-subquery-scoring-optimization/
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.