Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use or operator with textCriteria #3622

Closed
ovu opened this issue Apr 10, 2021 · 4 comments
Closed

Cannot use or operator with textCriteria #3622

ovu opened this issue Apr 10, 2021 · 4 comments
Assignees
Labels
status: duplicate A duplicate of another issue

Comments

@ovu
Copy link

ovu commented Apr 10, 2021

Hello, I have the following query that works in mongo using a client, it uses an or operator which combines the result of a text index and a normal attribute.

db.getCollection('person')
.find(
{$or: [ { "hrNumber": "123"} , { $text: { $search: "123" } }] } )

However, I cannot create a query using the opOperator, because it only accepts Criteria and not TextCriteria. Why is that restriction? It is a feature that is not supported or there is another way create the query as described below?

   val query= org.springframework.data.mongodb.core.query.Query()
   query.addCriteria(Criteria().orOperator( textCriteria, hrNumberCriteria))
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 10, 2021
@schauder schauder added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 12, 2021
@kioyong
Copy link
Contributor

kioyong commented May 2, 2021

@ovu try use @query annotation to customer query

@Repository
public interface PersonRepository extends MongoRepository<Person,String> {
    
    @Query("{$or: [ { hrNumber: ?0 } , { $text: { $search: ?1 } }] }")
    List<Person> findByCustom(String hrNumber, String text);
}

@christophstrobl christophstrobl added status: duplicate A duplicate of another issue and removed type: enhancement A general enhancement labels Mar 7, 2023
@christophstrobl
Copy link
Member

will be addressed by #3895 / #3884

@NerminKarapandzic
Copy link

is there any progress on this, the issues that you linked which are supposed to solve this are from 2021 and they're still open...

@ovu
Copy link
Author

ovu commented Dec 7, 2024

Hi, I am not working with that library anymore. I cannot say if the issue was solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

6 participants