My search block is set up to use the product and product_kit content types. I search by a term in a blog post I created and it returned the post when the dropdown list is set to "Any". When I selected product from the dropdown list, it worked correctly, the blog post wasn't returned. Is it designed to work this way? Thought as long as it's set to specific content types or taxonomies, the result with be limted to their content even if "Any" is selected.

CommentFileSizeAuthor
#10 restricts.jpg76.79 KBjdanthinne
#9 csearch.png8.16 KBfehin
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jdanthinne’s picture

If a content type is selected, it will search only for node in this content type.
If "Any" is selected, it will search for node without a particular content type (regular search).

The dropdown list is just a selector, and not a restrictor when using "Any".

BUT that's a good question/remark... that made me think perhaps I should add settings to exclude some content types from the search and/or the ability the leave the "Any" field blank, so the user would have to choose which content type to search.
What do you think?

fehin’s picture

I think it would be nice to have the option of "Any" and not force the person to choose. Setting a search block up to search within specific content types or taxonomy means we want people to be able to search within all the specified block settings or select one to search in. I won't advise forcing users to pick, they should have the option to search by "Any" and get result based on only the specified block search setup or pick an option from the dropdown list.

jdanthinne’s picture

Status: Active » Needs work
fehin’s picture

Hi, have you decided what to do with this? Using myself and my friends as examples, people generally first search without picking an option from the list then if there is a lot of result, they select and option from the select list to filter the result. So it's is important that "Any" is restricted to the search configuration chosen by admin.

jdanthinne’s picture

Hi, I've decided to implement those settings, but it needs some work, and I'm pretty busy these days (I'm working full time for a webdesign company, so I can only do that on free time).
I'll update this issue as soon as I've done the work. Sorry for the delay.

jdanthinne’s picture

Status: Needs work » Needs review

Just commited the changes to DEV. Please review.
There's a new checkbox in the Custom Search / Content settings (and per block as well) where you can choose the behaviour of -Any-. (check it in your case)

fehin’s picture

Thank you for making the change. I installed the dev version but I couldn't find the check box. Where is it situated and what does it say?

jdanthinne’s picture

It's in /admin/settings/custom_search/content.
The last checkbox on the page ("Choosing -Any- restricts the search to the selected content types.")

fehin’s picture

FileSize
8.16 KB

This is not showing in mine. Please see attached image which shows the bottom of my "admin/settings/custom_search/content" page. Also would this only be available for contents and not taxonomy?

jdanthinne’s picture

FileSize
76.79 KB

Are you sure you have the latest dev version? Re-download it please.
See my screenshot.

fehin’s picture

I downloaded it again and tested it and it works. Thank you.
Would you please also make this option available for the taxonomies?

jdanthinne’s picture

I don't understand the point of making this option for taxonomy. For the content types, ok, because you can choose which types to include in the selector, but for the taxonomy, you can't choose the terms. -Any- would search for nodes with all terms??

fehin’s picture

The reason I asked you to add the function to the taxonomies is because the problem is the same. If the dafault "Any", in my case "catalog" is chosen, the result includes all matching values from the whole site not just within the taxonomy setting for the block.

jdanthinne’s picture

I think it's impossible to do (but correct me if I'm wrong or send me a link to a page where you want to do that)

Let's think that there's 2 taxonomy selectors, and they are both set to -Any-, how can I know the results to display? All nodes with taxonomy 1 or all with taxonomy 2?

jdanthinne’s picture

Status: Needs review » Closed (works as designed)
subhojit777’s picture

Version: 6.x-1.3 » 7.x-1.13
Status: Closed (works as designed) » Active

Opening this issue again. I have a custom search block where in settings I have specified three content types to be shown in search results. I have also checked the checkbox Choosing -Any- restricts the search to the selected content types. But it is not working. If I select - any - and search, it is searching in all content types, I guess this is not the expected behavior. If I select a particular type in the select list then it is searching for that content type, this is working as expected.

I am using apachesolr 7.x-1.4 and facetapi 7.x-1.3 modules

jdanthinne’s picture

I've pushed some changes to the DEV version, sending the correct restricted content types to apachesolr: http://drupalcode.org/project/custom_search.git/commit/eb31739
Please test and review.