Page 1 of 1
Reduce by search: using multiple items you wish to exclude?
Posted:
Thu Feb 25, 2010 12:06 am
by paulc
Hi
I searched the forums and the user manual and not seen an example of how I can perform a search for items with a criteria I don't want.
eg I have a list of 5 records. I want to perform a search for items that aren't 2 and 4.
PID
1
2
3
4
5
I can use !2 to reduce the list to
PID
1
3
4
5
What I can't figure out is how to incorporate the other criteria. I have tried the following...all of which don't work...
!2||!4
!(2||4)
Re: How do you search for items not in a list your foundset?
Posted:
Thu Feb 25, 2010 1:02 am
by ptalbot
Don't know either but have you tried
!2&&!4 maybe?
Otherwise you will have to make a second search to restrain the foundset.
Re: How do you search for items not in a list your foundset?
Posted:
Thu Feb 25, 2010 7:22 pm
by paulc
hello ptalbot,
thanks for the info. I ended up going with a second search to filter out the other option. Doesn't seem like the most efficient method, but it works for now.
If you have any other suggestions, I would be really happy to hear them.
Thank you
Re: Reduce by search: using multiple items you wish to exclude?
Posted:
Fri Feb 26, 2010 12:17 am
by jcompagner
i think there is another way with just one query..
use foundset.addFoundSetFilterParam(dataprovider, "not in", new Array(2,4), "notin");
but then you have to remember that after that you have to remove it...
foundset.removeFoundSetFilterParam("notin");
but it could be nice that you also have this support in normal find mode.
Re: Reduce by search: using multiple items you wish to exclude?
Posted:
Fri Feb 26, 2010 1:04 pm
by rgansevles
Another option may be to use invertRecords:
- Code: Select all
if (foundset.find()
{
pid = 2
foundset.newRecord()
pid = 5
foundset.search() // 2||5
foundset.invertRecords() // !(2||5)
}
It does have the disadvantage of a double query.
If you want you can file a feature request for support of something like !(2||5) directly.
Rob
Re: Reduce by search: using multiple items you wish to exclude?
Posted:
Fri Feb 26, 2010 3:43 pm
by ptalbot
rgansevles wrote:Another option may be to use invertRecords:
- Code: Select all
if (foundset.find()
{
pid = 2
foundset.newRecord()
pid = 5
foundset.search() // 2||5
foundset.invertRecords() // !(2||5)
}
It does have the disadvantage of a double query.
If you want you can file a feature request for support of something like !(2||5) directly.
Rob
Then you can do this:
- Code: Select all
if (foundset.find()
{
pid = "2||5'";
foundset.search(); // 2||5
foundset.invertRecords(); // !(2||5)
}
don't you? No double query!
Re: Reduce by search: using multiple items you wish to exclude?
Posted:
Fri Feb 26, 2010 3:47 pm
by rgansevles
Patrick,
That is the same as my code.
The first query is triggered by the search() call, the second by the invertRecords() call.
Rob
Re: Reduce by search: using multiple items you wish to exclude?
Posted:
Fri Feb 26, 2010 3:55 pm
by ptalbot
rgansevles wrote:Patrick,
That is the same as my code.
The first query is triggered by the search() call, the second by the invertRecords() call.
Rob
Silly me
Thanks for clarifying!
Re: Reduce by search: using multiple items you wish to exclude?
Posted:
Mon Mar 01, 2010 8:27 pm
by paulc
HI
thanks for the posts. I went to try the suggestions, but I run into an issue where the user has already provided another filter. I failed to mention that the user will now have another filter they can set and the invert records method will return the inverted records of the other filter parameter as well.
eg I have a list of 5 records. I want to perform a search for items where pid != 2, 4 and category = 2,3.
PID Category
1 1
2 2
3 2
4 3
5 2
I can use !2 to reduce the list to
PID
1
3
4
5
OR
I can use PID = !2 and category = 2||3to reduce the list to
3
4
5
What I can't figure out is how to incorporate the other criteria. I have tried the following...all of which don't work...
!2||!4
!(2||4)
Re: Reduce by search: using multiple items you wish to exclude?
Posted:
Mon Mar 01, 2010 8:46 pm
by rgansevles
You can use some combinations with invertrecords() and search(clearLastResults=false) but that may get very hairy very quickly.
- Code: Select all
if (foundset.find())
{
pid = '2||5'
foundset.search()
foundset.invertRecords() // pid = !(2||5)
foundset.find()
category = '2||3'
foundset.search(false, true) // pid = !(2||5) && category = 2||3
}
As i said, quite hairy...
Rob
Re: Reduce by search: using multiple items you wish to exclude?
Posted:
Fri Sep 10, 2010 2:47 pm
by victor.rojo
jcompagner wrote:use foundset.addFoundSetFilterParam(dataprovider, "not in", new Array(2,4), "notin");
Is the "not in" a valid operator?
I'm trying to use it and doesn´t work...
Re: Reduce by search: using multiple items you wish to exclude?
Posted:
Fri Sep 10, 2010 6:29 pm
by rgansevles
Victor,
This is actually not working correctly, I have fixed that for release 5.2.2.
Rob
Re: Reduce by search: using multiple items you wish to exclude?
Posted:
Mon Sep 13, 2010 8:22 am
by victor.rojo
Ok, thanks Rob.