I want to fire up a query in luke for luncene indexed document. I want to sort the results before they are fetched. What is the lucene syntax to sort the data. I don't need java/or-language-specific code to sort; instead raw lucene syntax to sort the data?
Can anyone give me a sample example for sorting by 2 fields in descending order?
Cheers
Lucene queries don't have a sort syntax. You have to use the Sort object in your implementation of lucene if you need to sort
Related
Can the basics of elastic search be implemented using a nosql database by performing the following steps? For each document to index:
Generate n-grams from text
Insert n-gram into table where the n-gram is the key and a list of matching documents is the value
your question is a little confusing here, as Elasticsearch is a nosql datastore and it can create ngrams. you can also search for a word/value and then return matching documents
perhaps explaining a little more on what you are trying to achieve, ie the use case, would help provide a clearer answer
It is a good solution for convenience, if I put some data into elasticsearch index, which fields only using in _source parameter, not for search, or sort? Theese datas are stored in SQL too, but it's easier to access from elasticsearch, not needed plus SQL call. Is this a good direction?
Yes, You can access the field value from _source if you want to avoid the call to SQL, and better performance. And yes, IMO it's a good direction if you are thinking to call SQL just for retrieving these field values. fetching values from ES will be more efficient.
You can and should disable the index option on the field, where you don't need to search.
Also, refer to source filtering for more information.
Can We use MLT concept of ES to filter documents with similar fields.Is it possible to give weight to the individual field. What is elastic search recommendations.
Yes you can: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html According to your fields, this could be easy or difficult.
can someone please in simple sentences explain what is elasticsearch aggregation exactly?
I searched but everywhere there are some explanations about how to use it, and about syntax.
but I can't understand the reason why they exist. what is their main purpose.
what kind of query they've build for ?
I need trend tags (suggest terms in search as you type ) in my search system
I faced elastic aggs , and I have no Idea what they are.
If you know SQL, elasticsearch aggregations are kind of group by clause of elasticsearch.
You can aggregate(group by) on field you want, can have document count on that field, can also have all the documents in that group, can have nested aggs(group by).
For suggest terms in search as you type aggs will not work .. you need to read about analysis document ... or read about fuzzy query in elasticsearch.
I have a collection with thousands of documents each of which contains a string to be searched for. I would like to make an index for these strings like so:
index a "an apple"
index a "arbitrary value"
index s "something"
I think I will be able to improve the search performance if I create these indices so that when I search for 'something', I can only look up documents in the index 's'. I am new to database design and wonder if this is the right way to improve the performance of the queries with string values. Is there any better way to do this or does mongodb have a built in mechanism to achieve this kind of indexing? Please enlighten me.
You can create indexes based on the keys and not on the values.
Each document will have a default index created on the _id field.
You can also create compound Index, ie combining on or more fields
Creation of Index should be appropriate to your search, so that your search queries will be faster.
http://docs.mongodb.org/manual/indexes/