paulc
February 24, 2010, 10:06pm
1
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)
ptalbot
February 24, 2010, 11:02pm
2
Don’t know either but have you tried
!2&&!4 maybe?
Otherwise you will have to make a second search to restrain the foundset.
paulc
February 25, 2010, 5:22pm
3
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
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.
Another option may be to use invertRecords:
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
ptalbot
February 26, 2010, 1:43pm
6
rgansevles:
Another option may be to use invertRecords:
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:
if (foundset.find()
{
pid = "2||5'";
foundset.search(); // 2||5
foundset.invertRecords(); // !(2||5)
}
don’t you? No double query!
Patrick,
That is the same as my code.
The first query is triggered by the search() call, the second by the invertRecords() call.
Rob
ptalbot
February 26, 2010, 1:55pm
8
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
Silly me
Thanks for clarifying!
paulc
March 1, 2010, 6:27pm
9
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)
You can use some combinations with invertrecords() and search(clearLastResults=false) but that may get very hairy very quickly.
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
jcompagner:
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…
Victor,
This is actually not working correctly, I have fixed that for release 5.2.2.
Rob