Ignacio Valdés
Posts: 0
Joined: Wed Dec 11, 2013 7:21 pm

How to create a search with 5 variables?

With 1 variable works perfect:
return '{"name":{"$regex":"^'+value+'", "$options":"i"}}';

But does not work when using 2 or more variables:
return '{"name":{"$regex":"^'+value+'", "$options":"i"}, "brand":{"$regex":"^'+value+'", "$options":"i"}}';

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How to create a search with 5 variables?

Hello! Should be working... Your request means that name and brand fields should start with value of value variable. Is that request you want to send to DB?

Ignacio Valdés
Posts: 0
Joined: Wed Dec 11, 2013 7:21 pm

How to create a search with 5 variables?

Exactly! The console displays the following:
Image

I also add the following images:

Image
Imageinline.png?1386812846[/img] [/url]
Image

Thank you very much!

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

How to create a search with 5 variables?

Hi Ignacio,

Take a look at here please: https://getsatisfaction.com/apperyio/...

Ignacio Valdés
Posts: 0
Joined: Wed Dec 11, 2013 7:21 pm

How to create a search with 5 variables?

I try to do it but does not work for me :(

http://cl.ly/image/3f00140f1e2F

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

How to create a search with 5 variables?

Hi Ignacio,

This is not a valid JS code. If I understand what you want correctly, add this code for 'where' parameter: prereturn '{"brand":{"$in": ["model","age"]}}';/pre

Ignacio Valdés
Posts: 0
Joined: Wed Dec 11, 2013 7:21 pm

How to create a search with 5 variables?

I'm kinda lost, now it finds nothing :(
Image Image

Thanks!

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How to create a search with 5 variables?

Hello! With query you posted you want to get all records where in brand field either model or age. As we ca see from this screenshot https://d2r1vs3d9006ap.cloudfront.net... this is not what you need. Could you describe what you map to where parameter and what you expect to get?

Ignacio Valdés
Posts: 0
Joined: Wed Dec 11, 2013 7:21 pm

How to create a search with 5 variables?

I want to perform a compound search, so that the user can enter:
name of a car brand + car name + year of the car

The search result should be the price data of that car and specifications.

I hope I have explained correctly.

Thanks!

Image Image Image

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How to create a search with 5 variables?

Hello! Do you need user enter all search parameters in one Input (for example Volvo XC90 2004) or you have 3 Inputs for each value (please note it's better solution)? How do you want to implement this?

Return to “Issues”