Mongo DB spring boot - Bson query - bson

I am using spring-boot-starter-data-mongodb and I am creating a BSON query to execute a updateMany operation
The query is fairly simple. I want to find all documents whose _id is contained in String List
listOfStrings = List.of("123", "456");
Bson query = and(in("_id", listOfStrings));
but this query does not produce any match (documents with these IDs exist in the collection). If I use same query but with another field from the document, it will work fine.
Any idea how I can build this query ?

Related

Group by multiple fields in Spring Data MongoDB Aggregation

I have an aggregation operation criteria, and at some point, I need to group by two fields, but one of them is a nested field inside the object. I have this:
criteria.add(group("name", "amount.currency").count().as("number"))
But I get this error
FieldPath field names may not contain '.'
How can I group by multiple fields including nested ones in Spring Data MongoDB

What is difference between GetResponse and SearchResponse in 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.

what is the meaning of query *:value in lucene?

What is the meaning of this query in lucene ?
Query query =new QueryParser(Version.LATEST,"*",analyzer).parse("value");
It creates a QueryParser for the field "*" (I'm not sure if actual wildcards are allowed here - try!), using the specified analyzer. It then parses the textual query ("value") for that field. This returns a Query, which you can then use for searching through searcher.Search(query);.

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)

How to query elasticsearch without specifying which property to match

I have an elasticsearch document with multiple properties, like title, body, author.
I'd like to get results from a query that matches ANY of the fields.
Usually, I'll query by specifying a property to match. I'd rather write a more flexible query that will return the whole document if any of the properties are matched.

Resources