It looks like terms for search with Views2 filter always OR'ed and there is no built functionality to change it?

Example: we have nodes:
wild west
wild wild
west west

With core Search module on query "wild west" the result will be only:
wild west

With views search terms on the same query the result will be:
wild west
wild wild
west west
ie results = "wild OR west" query if using core search

Operators "AND", "OR" are accepted as search terms by Views2 filter, not as operators.

Live demo: http://demo.waysys.ru

how to change Views2 filter to use AND instead of OR?
(i really don't mind hacking core)

PS Why i'm using Views search filter instead of core search? I'm going to display search results in table with custom fields, only nodes of one type, sort by fields...

PPS Sorry for my english :)

Comments

fumbling’s picture

By the way, are you using the "Search: search terms" filter? I really like the older filter-by-keyword "search filter" that Views lets you apply (e.g. go to filters, choose Node: Title and then click the "expose" button) but I noticed it can't search on whole words only (e.g. a search on "art" will pull up node titles with "heart" and "cart"). Any idea how to get it to search on whole words? The "Search: search terms" option is something new I'm just now learning. That's really odd that they don't use the same logic as core search as you point out.

fumbling’s picture

I've decided to use the "Search: search terms" filter and am having the same issue as you, I need to switch to OR rather than AND. Were you successful in doing that?

gulliverrr’s picture

I have managed to use javascript inside views to manipulate the url parts to AND the various taxonomy terms
i.e.: example.com/wild/west
will only display wild west
and example.com/west
will display wild west and west

My problem is not finished yet as Im trying to have dynamic filtering as you click through the taxonomy terms.
Example again:
Imagine I have this simple structure:
Cars
-SUV
--Red SUV
--Blue SUV
-City Car
--Red City Car
--Blue City Car
Motobikes
...

From the beginning I want to be able to choose by color OR by vehicle (Car/Motobike) OR by vehicle type OR price range etc.
Once I select, say, Red, I want to see again the remaining filters (vehicle, vehicle type, price range) which upon selection will AND my selection with the selection(s) so far. Note I dont need to follow the path I have described above and I should be able to navigate to the same results no matter how I choose my filters.

Everybody points to use Views but after a loooot of experimenting I still cannot do it without the hacky "solution" of javascript which I dont like.
Any ideas?

merlinofchaos’s picture

Status: Active » Fixed

With the most current Views search terms filte,r it is the same as core. If you type term AND term the terms will be anded. If you type term term the terms will be ored. If you type 'term term term' phrase matching will be used.

teerex’s picture

merlinofchaos thanks,
Updated Views to 6.x-2.3

Works fine.

teerex’s picture

Status: Fixed » Closed (fixed)

gulliverrr
"From the beginning I want to be able to choose by color OR by vehicle (Car/Motobike) OR by vehicle type OR price range etc."
that will be the first one in chain

maybe write custom block for view filter?

Working custom block with filter parameters in view.
With some customizations i think you can get what you want exactly.

User writes search query and selects Categories with checkboxes. Current search query is saved.

<?php $keys=$_GET['keys']; //Get current search string from URL to print in form later ?> 

<div class="custom-search"><form action="/my-view" accept-charset="UTF-8" method="get" id="views-exposed-form-my-view-page-1">
<div style="text-align: center"><div class="string"><input type="text" maxlength="100" name="keys" id="edit-keys" size="50" value="<?php print $keys; //Print current search string ?>" title="Enter keywords." class="form-text" />
<input type="submit" id="edit-submit" value="Search"  class="form-submit" /></div></div>
<div class="content">
Select categories for search:
    <p><?php
$printme="";
$query="SELECT tid, name FROM {term_data} WHERE vid=1";
$queryresult = db_query($query);
while ($magaz = db_fetch_object($queryresult)) {
$printme .= "<input type=checkbox name=field_kat_value[] value=". $magaz->tid .">". $magaz->name ."<br/>";
}
print $printme; ?>
    </p>
</div>
</form>
</div>

P.S. maybe not secure and fast, it's only a draft