Skip to content

Commit

Permalink
Item13280: Upgrade to Solr-5 and more
Browse files Browse the repository at this point in the history
- removed field "collection" as this conflicts with solr terminology
- fixed solr::defaultweb in SolrSearchBaseTemplate
- improved look and feel of person search
- disabled default values for $Foswiki::cfg{SolrPlugin}{SkipTopics}
- removed $Foswiki::cfg{SolrPlugin}{DefaultCollection} config param
- initial work on additional crawlers, e.g. a filesystem crawler
- disabled commit messages to solr to let it auto-commit on its own for better throughput
- fixed erroring out due to invalid TOPINCINFOs
- added configset for foswiki to be copy-pasted into the solr server
- adjusted and improved all of solrindex.xml and schema.xml
- upgraded to WebService::Solr 0.23
- disabled utf8 encoding in WebService::Solr by default
- fixed spelling suggestions in ajax-solr: the collations have been moving around in the response json
- fixed viewtopbar.solr.tmpl for PatternSkin
- fixed field mapping and facetting for +value formfields
  • Loading branch information
MichaelDaum committed Feb 25, 2015
1 parent ad63ccd commit ae97ee8
Show file tree
Hide file tree
Showing 134 changed files with 7,034 additions and 6,755 deletions.
2 changes: 1 addition & 1 deletion data/System/NatSkinSolrSearchViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1411635852" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1424859947" format="1.1" version="1"}%
%META:TOPICPARENT{name="SolrSearchViewTemplate"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"SolrSearchView"}%
Expand Down
2 changes: 1 addition & 1 deletion data/System/NatSkinWebChangesViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1411635852" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1424859947" format="1.1" version="1"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"WebChangesView"}%
%{</verbatim>}%
Expand Down
2 changes: 1 addition & 1 deletion data/System/PatternSkinSolrSearchViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1411635852" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1424859947" format="1.1" version="1"}%
%META:TOPICPARENT{name="SolrSearchBase"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"SolrSearchBase"}%
Expand Down
2 changes: 1 addition & 1 deletion data/System/PatternSkinWebChangesViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1411635852" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1424859947" format="1.1" version="1"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"WebChangesView"}%
%{</verbatim>}%
Expand Down
2 changes: 1 addition & 1 deletion data/System/SiteChangesViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1411635852" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1424859947" format="1.1" version="1"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"WebChangesView"}%
%{</verbatim>}%
Expand Down
9 changes: 4 additions & 5 deletions data/System/SolrPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1411635852" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1424859947" format="1.1" version="1"}%
%META:TOPICPARENT{name="Plugins"}%
---+ Solr Plugin
%SHORTDESCRIPTION%
Expand Down Expand Up @@ -455,7 +455,7 @@ A lucene document is made up of fields of a certain type which defines the way t
by the solr server. This is configured in the =schema.xml= file.

While the schema is able to cover all Foswiki related data it is still kept generic enough to be used for non-wiki
content as well. Different kinds of content are distinguished using the =collection= field (see below).
content as well.

---+++ Field types

Expand Down Expand Up @@ -495,7 +495,6 @@ useful for spatial search.
| timestamp | tdate | | stored | time when the document was added to the index |
| spell | text_spell | multivalued | | used for spellchecking |
| id | string | | stored | unique identifier for each document; this is the _external_ id usable in applications; there's an internal solr document id not related to this field |
| collection | string | | stored | identifies a set of documents comming from the same content collection; by default all content stored in Foswiki (topics and attachments) is gathered in the =wiki= collection set in =Foswiki::cfg{SolrPlugin}{DefaultCollection}= |
| language | string | | stored | language of the current document; this may be specified explicitly using the =CONTENT_LANGUAGE= preference, or set to "detect" to let the solr update chain detect the language automatically |
| url | string | | stored | url used to access the document being indexed |
| type | type | | stored | holds the type facet of the document; this is "image" for all kinds of images, "video" for all kinds of videos, "topic" for Foswiki topics and the verbatim file extension for everything else; note: plugins like Foswiki:Extensions/MetaCommentPlugin might use specific types as well (like "comment" in this case) |
Expand Down Expand Up @@ -738,5 +737,5 @@ specific search applications. The destination fields are then analysed using the
| 22 Nov 2010: | fixes integration with pattern skin |
| 18 Nov 2010: | initial public release |

%META:FILEATTACHMENT{name="SolrPluginSnap1.png" attachment="SolrPluginSnap1.png" attr="" comment="" date="1411635852" size="93552" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="SolrPluginSnap2.png" attachment="SolrPluginSnap2.png" attr="" comment="" date="1411635852" size="158013" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="SolrPluginSnap1.png" attachment="SolrPluginSnap1.png" attr="" comment="" date="1424859947" size="93552" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="SolrPluginSnap2.png" attachment="SolrPluginSnap2.png" attr="" comment="" date="1424859947" size="158013" user="ProjectContributor" version="1"}%
2 changes: 1 addition & 1 deletion data/System/SolrSearch.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1411635852" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1424859947" format="1.1" version="1"}%
%META:TOPICPARENT{name="WebHome"}%

%META:PREFERENCE{name="VIEW_TEMPLATE" title="VIEW_TEMPLATE" type="Set" value="SolrSearchView"}%
4 changes: 2 additions & 2 deletions data/System/SolrSearchBaseTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1411635852" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1424859947" format="1.1" version="1"}%
%META:TOPICPARENT{name="SolrPlugin"}%
%{<verbatim class="tml">}%
%{ ###########################################################################
Expand Down Expand Up @@ -37,7 +37,7 @@
content: main definition that puts together all pieces
}%
%TMPL:DEF{"content"}%<noautolink>
<div id='solrSearch' style='display:none' data-more-fields='%TMPL:P{"solr::fields"}%' data-solr-url='%SCRIPTURL{"rest"}%/SolrPlugin/proxy' data-solr-params='{"topic": "%WEB%.%TOPIC%", "qt":"%TMPL:P{"solr::defaultquerytype"}%", "rows": %TMPL:P{"solr::defaultrows"}%}' data-extra-filter='%TMPL:P{"solr::extrafilter"}%%IF{"'%TMPL:P{"solr::defaultweb"}%'!='all'" then=" web:%TMPL:P{"solr::defaultweb"}%"}%'>
<div id='solrSearch' style='display:none' data-more-fields='%TMPL:P{"solr::fields"}%' data-solr-url='%SCRIPTURL{"rest"}%/SolrPlugin/proxy' data-solr-params='{"topic": "%WEB%.%TOPIC%", "qt":"%TMPL:P{"solr::defaultquerytype"}%", "rows": %TMPL:P{"solr::defaultrows"}%}' data-extra-filter='%TMPL:P{"solr::extrafilter"}%'>
%TMPL:P{"solr::title"}%<!-- -->
%TMPL:P{"solr::header"}%<!-- -->
%TMPL:P{"solr::hits"}%<!-- -->
Expand Down
2 changes: 1 addition & 1 deletion data/System/SolrSearchViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1411635852" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1424859947" format="1.1" version="1"}%
%META:TOPICPARENT{name="SolrSearchBase"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"SolrSearchBase"}%
Expand Down
2 changes: 1 addition & 1 deletion data/System/SolrSideBar.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1411635852" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1424859947" format="1.1" version="1"}%
---+!! %TOPIC%

This is a set of widgets to be used in a sidebar navigation. This is used like this:
Expand Down
18 changes: 8 additions & 10 deletions data/System/SolrWikiUsersViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1411635852" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1424859947" format="1.1" version="1"}%
%META:TOPICPARENT{name="WebHome"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"SolrSearchView"}%
Expand Down Expand Up @@ -58,23 +58,21 @@
{{include tmpl="#solrHitTemplate_userimage" /}}
<h4><a href='{{:url}}'>{{:title}}</a></h4>
<ul class='foswikiTopicInfo jqShrinkUrls' data-size='15'>
{{if field_Profession_s}}<li>%MAKETEXT{"Profession"}%: {{:field_Profession_s}}</li>{{/if}}
{{if field_Telephone_s}}<li>%MAKETEXT{"Tel"}%: {{:field_Telephone_s}}</li>{{/if}}
{{if field_Email_s}}<li>%MAKETEXT{"Email"}%: <a href='mailto:{{:field_Email_s}}'>{{:field_Email_s}}</a></li>{{/if}}
{{if field_Location_s}}<li>%MAKETEXT{"Location"}%: {{:field_Location_s}}</li>{{/if}}
{{if field_Telephone_s}}<li>%JQICON{"fa-phone"}% {{:field_Telephone_s}}</li>{{/if}}
{{if field_Email_s}}<li>%JQICON{"fa-inbox"}% <a href='mailto:{{:field_Email_s}}'>{{:field_Email_s}}</a></li>{{/if}}
{{if field_Location_s}}<li>%JQICON{"fa-tag"}% {{:field_Location_s}}</li>{{/if}}
</ul>
</div>
</script>%TMPL:END%
%{</verbatim>}%

%{<verbatim>}%
%TMPL:DEF{"solr::templates::userimage"}%<script id="solrHitTemplate_userimage" type="text/x-jsrender">
<div class='foswikiImage foswikiLeft'>
{{if thumbnail}}
<img src='%SCRIPTURLPATH{"rest"}%/ImagePlugin/resize?topic={{:web}}.{{:topic}};file={{:~encodeURIComponent(thumbnail)}};size=60x80>;crop=on' alt='{{:name}}' />
<div class='foswikiImage foswikiLeft' style='background-image:url({{if thumbnail}}
%SCRIPTURLPATH{"rest"}%/ImagePlugin/resize?topic={{:web}}.{{:topic}};file={{:~encodeURIComponent(thumbnail)}};size=80x100>;crop=on
{{else}}
<img src='%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/images/nobody.gif' height='80' />
{{/if}}
%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/images/nobody.gif
{{/if}})'>
</div>
</script>%TMPL:END%
%{</verbatim>}%
Expand Down
2 changes: 1 addition & 1 deletion data/System/WebChangesViewTemplate.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1411635852" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1424859947" format="1.1" version="1"}%
%{<verbatim class="tml">}%
%TMPL:INCLUDE{"SolrSearchBase"}%
%{</verbatim>}%
Expand Down
6 changes: 1 addition & 5 deletions lib/Foswiki/Plugins/SolrPlugin/Config.spec
Expand Up @@ -9,7 +9,7 @@ $Foswiki::cfg{SolrPlugin}{SkipWebs} = 'TWiki, TestCases';
# List of topics to skip.
# Topics can be in the form of Web.MyTopic, or if you want a topic to be excluded from all webs just enter MyTopic.
# For example: Main.WikiUsers, WebStatistics
$Foswiki::cfg{SolrPlugin}{SkipTopics} = 'WebRss, WebSearch, WebStatistics, WebTopicList, WebLeftBar, WebPreferences, WebSearchAdvanced, WebIndex, WebAtom, WebChanges, WebCreateNewTopic, WebNotify';
$Foswiki::cfg{SolrPlugin}{SkipTopics} = '';

# **STRING**
# Comma seperated list of extenstions to read, Their metadata is added to the index in any case.
Expand Down Expand Up @@ -85,10 +85,6 @@ $Foswiki::cfg{SolrPlugin}{SolrStartCmd} = '$Foswiki::cfg{ToolsDir}/solrstart %SO
# located and where solr puts its data further down the directory structure.
$Foswiki::cfg{SolrPlugin}{SolrHome} = '';

# **STRING**
# Default collection where to put foswiki content to (including topic text as well as all attachments)
$Foswiki::cfg{SolrPlugin}{DefaultCollection} = 'wiki';

# **PERL**
# List of supported languages. These are the locale IDs as supported for by the schema.xml configuration
# file for solr. For each language ID there's a text field named text_&lt;ID&gt; that will be filled
Expand Down
112 changes: 112 additions & 0 deletions lib/Foswiki/Plugins/SolrPlugin/Crawler.pm
@@ -0,0 +1,112 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2012-2014 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

package Foswiki::Plugins::SolrPlugin::Crawler;
use strict;
use warnings;

use Foswiki::Plugins::SolrPlugin::Base ();
our @ISA = qw( Foswiki::Plugins::SolrPlugin::Base );

################################################################################
sub crawl {
die "not implemented";
}

################################################################################
sub getListOfUsers {
die "not implemented";
}

################################################################################
sub getGrantedUsers {
die "not implemented";
}

################################################################################
sub getAclFields {
my $this = shift;

my @aclFields = ();

# permissions
my @grantedUsers = $this->getGrantedUsers(@_);
foreach my $wikiName (@grantedUsers) {
push @aclFields, 'access_granted' => $wikiName;
}

return @aclFields;
}

################################################################################
sub isIndexableFile {
my ($this, $fileName) = @_;

my $extension = '';
if ($fileName =~ /^(.+)\.(\w+?)$/) {
$extension = lc($2);
}
$extension = 'jpg' if $extension =~ /jpe?g/i;

my $indexFileTypes = $this->indexFileTypes();

return $indexFileTypes->{$extension};
}

################################################################################
sub indexFileTypes {
my $this = shift;

my $indexFileType = $this->{_indexFileType};

unless (defined $indexFileType) {
$indexFileType = {};
my $fileTypes =
$this->{fileTypes} ||
$Foswiki::cfg{SolrPlugin}{IndexExtensions} || # backwards compatibility
"txt, html, xml, doc, docx, xls, xlsx, ppt, pptx, pdf, odt";

foreach my $tmpFileTypes (split(/\s*,\s*/, $fileTypes)) {
$indexFileType->{$tmpFileTypes} = 1;
}

$this->{_indexFileType} = $indexFileType;
}

return $indexFileType;
}

################################################################################
sub getStringifiedVersion {
my ($this, $fileName) = @_;

# TODO: add caching similar to Foswiki::Plugins::SolrPlugin::Indexer
my $body = '';

my $extension = '';
if ($fileName =~ /^(.+)\.(\w+?)$/) {
$extension = lc($2);
}
$extension = 'jpg' if $extension =~ /jpe?g/i;

my $indexFileTypes = $this->indexFileTypes();

if ($indexFileTypes->{$extension}) {
$body = Foswiki::Contrib::Stringifier->stringFor($fileName) || '';
}

return $body;
}

1;

0 comments on commit ae97ee8

Please sign in to comment.