Filter RSS feed by multiple parameters

dschatz
User offline. Last seen 42 weeks 2 days ago. Offline
Joined: 04/18/2011
Points: 10

 Hi,

i'm trying to retrieve data from a RSS feed (works just fine) and filter the results/individual postings against a list of criteria in a CSV file. So simply put i'd like to check each RSS object if it contains any of the words in the CSV file; if a RSS object contains one of the filter words i want to see it as output. I tried to build this with invoke/filter in the mashup wires but it doesnt work.

Error execution Mashup Script : Error filtering data : null [ Line # 2] ( ) 

If i use input block as filter criteria instead of the CSV data it works just fine. Any suggestions how to make sure Presto is looping through each value in the CSV file correctly?

Thanks

0
Your rating: None
smitchell
smitchell's picture
User offline. Last seen 2 weeks 5 days ago. Offline
Joined: 08/29/2008
Points: 34

Not sure what happened, but the content of your post didn't show up. If you have a question , please reply or post again.

Sara, technical writer/jackbe

 

dschatz
User offline. Last seen 42 weeks 2 days ago. Offline
Joined: 04/18/2011
Points: 10

 Odd, i had to edit it. It should display ok now.

Thanks

smitchell
smitchell's picture
User offline. Last seen 2 weeks 5 days ago. Offline
Joined: 08/29/2008
Points: 34

Well that fixed the problem.

I think it depends on how your CSV data is structured in terms of using it as a filter criteria. And whether you are creating the mashup in Wires or using EMML directly.

If you're doing this in Wires, the easiest way is to get all the terms from your CVS into one string that is separated with spaces and use that as your single filter criteria. Filter treats each word as a potential match. This solution depends on each search tems being a single word and not a phrase. So say your CVS looks something like this:

name, query, anotherfield
"aaa","apple","bbb"
"ccc","orange","ddd"

If you register your CVS as a mashable, you can drag this mashable into your mashup. The results in Wires would look something like this:

<records>
<record><name>aaa</name><query>apple</query><anotherfield>bbb</anotherfield></record>
...
</records>

If you use the Extract block and select the <query> nodes from this mashable result, what you get is a single string with just the query values, separated by commas. You may need to use something like Data Decorator to replace the commas with spaces. You now have a block whose string result is the combination of all your query terms.

Add the RSS field to the canvas and Filter. When you create the filter criteria, you would compare the item/title node and use Matches. Then for the right hand of the criteria, choose the result of the block with the final query terms you have extracted. If you want to search in item/description also, add another filter criteria and use the same block results as the right hand value. Be sure that the combination operator is or (applies to any of these criteria).

For videos and more info on Extract and Data Decorator, see http://www.jackbe.com/prestodocs/v3.0/wires/extractAction.html and http://www.jackbe.com/prestodocs/v3.0/wires/dataDecorateAction.html.

If your query terms are not guaranteed to be single words, it gets a little more complicated. In that case, it may be simpler to work in EMML directly, as you have the full strength of <foreach> and can loop through each query term individually and apply the filter. Use <appendresult> to add the results of each loop filter to those from previous loops.

Sara, technical writer/jackbe

 

dschatz
User offline. Last seen 42 weeks 2 days ago. Offline
Joined: 04/18/2011
Points: 10

 Thank you Sara. I indeed tried it in Wires and following your advise worked in this case. Out of interest; would you be so kind and show an example how to achieve this specific case in EMML with a loop?