What is difference between GetResponse and SearchResponse in ElasticSearch? - elasticsearch

Recently I have reading some old coded written in the company and I did not understand the difference between two classes of ElasticSearch. It looks like GetResponse is trying to fetch data given some constraints that are intrinsic properties of tables like _index, _type, etc. I am not sure if my understanding is correct or not.

GetRequest is for getting a single document by ID and returns a GetResponse.
SearchRequest is for sending a search request (with query DSL) and retrieve a SearchResponse containing a set of documents matching the query.

Related

List firestore collection ids filtered by criteria

In Go package for firestore I can easily get list of IDs by doing something like
client.Collection("mycollection").DocumentRefs()
with query I can easily filter documents before I can iterate over them
client.Collection("mycollection").Where("x", "==", "y").Documents()
But Query seems to be missing an option to get just the .DocumentRefs() is there some way to get list of DocumentRefs matching specific query without actually fetching all the matching Documents (incuring read costs for each)?
The bottom line is that after I apply the filtering logic to get constrained list of doc IDs I want to run additional regex based filtering on the values of the IDs, and the list of filtered IDs is my final result, no need fr fetching docs.
Firestore queries always return the entire contents of every matching document. There are no "light" queries that just return document IDs or references. This is the case for all provided Firestore SDKs, not just go.
In general, it's advisable not to store data in the ID of a document for the purpose of filtering. Your use case will work better if you're able to precompute the conditions where a document should match, and put that data in a field of the document. It should be noted also that Firestore doesn't support regex type queries, as those do not scale massively as Firestore requires.

ElasticSearch: how to perform search across multiple fields using Java High Level REST Client?

I am looking at this tutorial and it describes how ES search could be executed against an index, but the search is done only using one field of each document:
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
sourceBuilder.query(QueryBuilders.termQuery("user", "kimchy"));
I would like to perform my search against multiple fields: like user name, display name, email etc.
Should I use Multi-Search API to achieve it?
https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-high-multi-search.html
MultiMatchQueryBuilder allows to do it, thanks to Abhay for helping me to find the proper solution.
https://snapshots.elastic.co/javadoc/org/elasticsearch/elasticsearch/6.4.0-SNAPSHOT/org/elasticsearch/index/query/MultiMatchQueryBuilder.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html

Possible to use GroupBy in ElasticSearch querystring?

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...

How do I combine Facet and FilterQueries using Spring data Solr?

Is it possible to combine a facet and field query in spring data solr? Something that would build a query like this:
> http://localhost:8983/solr/myCore/select?q=lastName%3AHarris*&fq=filterQueryField%3Ared&wt=json&indent=true&facet=true&facet.field=state
In other words, how do I add FilterParameters to a SimpleFacetQuery?
Any/all replies welcome, thanks in advance,
-- Griff
I assume you're using Spring Data Solr, from your reference to SimpleFacetQuery. Based on your sample query, the code would look something like this:
// creates query with facet
SimpleFacetQuery query = new SimpleFacetQuery(
new Criteria("lastName").startsWith("Harris"))
.setFacetOptions(new FacetOptions()
.addFacetOnField("state"));
// filter parameters on query
query.addFilterQuery(new SimpleFilterQuery(
Criteria.where("filterQueryField").is("red")));
// using query with solrTemplate
solrTemplate.queryForFacetPage(query, YourDocumentClass.class)

Getting a list of fields for an index in elasticsearch with nest

I would like to get a list of fields that I can query for a certain index in elasticsearch by using nest.
I know I can do a
Get _mapping
via http and that gets me more or less what I want. But I'm a bit stumped by Nest.
I looked in the
Dim _client = New ElasticClient(setting)
Dim mapping = _client.GetMapping(Function(x) x.Index(Of TexCaseElastic)())
but could not really find my way.
I got it. It's in the properties property.
For Each s In mapping.Mapping.Properties
Console.WriteLine(s.Key.Name)
Next
Where the name of the key is the name of the field.

Resources