# Partial Search

**URL:** <https://rubytalk.org/t/partial-search/43084>\
**Category:** ruby-talk\
**Created:** [17 December 2007 09:40 UTC](https://rubytalk.org/t/partial-search/43084 "2007-12-17T09:40:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ruby\_Geo](https://avatars.discourse-cdn.com/v4/letter/r/977dab/32.png) [@Ruby\_Geo](https://rubytalk.org/u/Ruby_Geo)\
**Post date:** [17 December 2007 09:40 UTC](https://rubytalk.org/t/partial-search/43084/1 "2007-12-17T09:40:05Z")

</div>

Can someone please help me to adjust the folowing method into  
displaying  
&nbsp;&nbsp;&nbsp;using a flag. Basically what I want it to do it have an array of  
keywords  
&nbsp;&nbsp;&nbsp;and a flag which asks partial match or exact

&nbsp;&nbsp;&nbsp;These are the keywords.

> **···**
>
> ------------------------
> 
> &nbsp;&nbsp;&nbsp;KEYWORDS =["Sole Trader", "Retail", "Builder", "Internet"]
> 
> &nbsp;&nbsp;&nbsp;And this is the current method.  
> &nbsp;&nbsp;&nbsp;-------------------------
> 
> &nbsp;&nbsp;&nbsp;def self.search\_by\_keyword(businesses, searched\_keyword)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;businesses.select do |b|  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b.my\_keywords.include?(searched\_keyword)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> &nbsp;&nbsp;&nbsp;end
> 
> &nbsp;&nbsp;&nbsp;It has to me something like this.  
> &nbsp;&nbsp;&nbsp;----------------------------
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def self.search\_by\_keyword(businesses, searched\_keyword\_as\_array,  
> flag\_exact\_or\_partial\_match)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;businesses.select do |b|  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b.my\_keywords.include?(searched\_keyword)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> &nbsp;&nbsp;&nbsp;en  
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
