0

I have a mongodb collection with multiple fields and nested ones, also the value are strings and numbers.
I want to search through all or just some specific fields and return the data to the user from my API which is built with Spring Boot.
I could search using an index only for String values but not numbers.
Here is what the data looks like :

{
"id": "string",
"type": "atm",
"request_id": "string",
"state": "created",
"reason_code": "string",
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"completed_at": "2019-08-24T14:15:22Z",
"scheduled_for": "2019-08-24",
"related_transaction_id": "77cf4c8f-163c-4c22-acc4-3cade5f744f0",
"merchant": {
"name": "string",
"city": "string",
"category_code": "string",
"country": "string"
},
"reference": "string",
"legs": [
{
"leg_id": "b1c630e1-a27d-4ede-94f0-ee42391a3c4e",
"amount": 0,
"fee": 0,
"currency": "string",
"bill_amount": 0,
"bill_currency": "string",
"account_id": "449e7a5c-69d3-4b8a-aaaf-5c9b713ebc65",
"counterparty": {},
"description": "string",
"balance": 0
}
],
"card": {
"card_number": "string",
"first_name": "string",
"last_name": "string",
"phone": "string"
}
}

The fields i wanna search through are ID, refernce ,Legs.amount, Legs.description.

Any Help would be appreciated ,Thanks in advance

3
  • are you looking for something like this? Commented Feb 10, 2022 at 13:23
  • thank you for responding, but not what im looking for. simply just to query the database, like a generic search functionality Commented Feb 10, 2022 at 13:42
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Feb 22, 2022 at 13:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.