Comments

pwolanin’s picture

Sure, however we need to index that information, otherwise there is nothing to facet.

jody lynn’s picture

Assigned: Unassigned » jody lynn

I should have this working shortly.

jody lynn’s picture

Status: Active » Needs review
StatusFileSize
new3.09 KB

This is working- it indexes book bid's and has a facet for the book a book node belongs to and a block to filter by book.

pwolanin’s picture

One initial suggestion - you might want to index a bid of 0 for nodes not in any book (see the OG integration) in order to facet/filter-out those nodes not in any book.

pwolanin’s picture

An alternative is here: http://www.nabble.com/How-to-know-if-a-field-is-null--td19114164.html

something like: &fq=-is_book_bid:[* TO *]

but I think there is still an outstanding issue to make the query class support negative queries.

jody lynn’s picture

StatusFileSize
new3.14 KB
jody lynn’s picture

Hmm, my comment disappeared.
I just added 0 for non-books in the index and display them as 'No Book' (that part was actually in my previous patch already due to following og integration logic)

jody lynn’s picture

Also I just made a module which provides a search/book-search/BID menu callback to display solr search results within a particular book. It also adds a search bar to book nodes for search within that book. It relies on apachesolr_book. Is that better off as a separate contrib module?

It was more of a pain to do something like that than I expected - I followed the logic in project_solr.module. I wonder if some of the logic in apachesolr_search_search could be made into more of an API to create custom search pages free from the default search callback in an easier way.

pwolanin’s picture

Yes - we certainly intend to make refinements to the API to make this easier, there are a couple open issues.

pwolanin’s picture

Hmm, yes - just made an interesting observation: we can get a facet count for all those docs missing the field by adding to the params:

$params['f.is_book_bid.facet.missing'] = 'true';

This is better in many ways than indexing a 0, since it requires re-indexing only nodes in books, not all nodes.

This same technique should go in the OG module - the only trick is figureing out how to make a proper facet link.

pwolanin’s picture

doing this get results back like:

            [im_vid_1] => stdClass Object
                (
                    [_empty_] => 20
                )

So you can look for the key "_empty_" as we do already for language.

pwolanin’s picture

pwolanin’s picture

Given that book module is in core and the code here is pretty minimal, we should probably just make this part of the main module - especially if we can get the negative queries working right.

Also, did you just copy this over and modify from the OG module?

$params['fl'] .= ',is_book_bid';

I think I added that kind of code there since we were considering adding links to the groups to each search result. Based on the code here, there's no read to add the bid to search results.

pwolanin’s picture

hey, just realized that you're the fabulous Jody that AlexUA kept mentioning at our meetup!

Anyhow - I need to sort the minor APi changes for the Views integration people, then we can toss in the negative query support and this faceting will be like 10 lines in the main module (like it supports taxonomy now).

pwolanin’s picture

StatusFileSize
new9.37 KB

ok, this is basically working (includes some other misc improvements).

taxonomy doesn't properly handle missing facets, and I'm not sure about language.

pwolanin’s picture

StatusFileSize
new9.36 KB

stray !

pwolanin’s picture

StatusFileSize
new10.54 KB

plus breadcrumb theme function and better handling for $node->language.

damien tournoud’s picture

Two remarks:

+  $face_missing = variable_get('apachesolr_facet_missing', array());

should probably be $facet_missing

+/**
+ * Enable facet missing for books.
+ */
+function apachesolr_search_update_6003() {
+  $ret = array();
+  $facet_missing = variable_get('apachesolr_facet_missing', array());
+  $facet_missing['apachesolr_search']['is_book_bid'] = 1;
+  variable_set('apachesolr_facet_missing', $facet_missing);
+  return $ret;
+}

and

+  // A book module facet.
+  $facets['is_book_bid'] = array(
+    'info' => t('Apache Solr Search: Filter by Book'),
+    'facet_field' => 'is_book_bid',
+  );

create the book facet unconditionnally, even if the book module is not enabled.

pwolanin’s picture

StatusFileSize
new10.61 KB

I think it's fine to set the facet_missing unconditionally, since it will have not effect absent the facet being used.

Patch with fixes for the other problems.

I'd like to find a way to use em tags or something for the missing facet - it's very non-obvious otherwise.

pwolanin’s picture

StatusFileSize
new10.58 KB

doxygen fix

jody lynn’s picture

Thanks Peter. I'll test it on our site shortly

pwolanin’s picture

StatusFileSize
new14.64 KB

Further improved - updated apachesolr_l() to handle $options['html']

pwolanin’s picture

Assigned: jody lynn » Unassigned
StatusFileSize
new15.22 KB

document apachesolr_l() a little.

pwolanin’s picture

Status: Needs review » Fixed

committed to 6.x

jody lynn’s picture

A bit late to the review, but the latest dev is working fine for us for book facet. We're planning to release a contrib module that adds a search bar to book pages which does search within that book.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.