Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TYPO3 Solr extension configuraiton sample

Constants

plugin.tx_solr {
	solr {
	scheme = http

	host = YY.YY.YY.YY
	port = 8080

	path = /solr/core_XXXX/
  }
  search {
	results {
	  resultsPerPage = 10
	}
  }
}

Setup

plugin.tx_solr {
  
  enabled = 1
  logging.query.queryString = 1

  solr {
	scheme = {$plugin.tx_solr.solr.scheme}
	host = {$plugin.tx_solr.solr.host}
	port = {$plugin.tx_solr.solr.port}
	path = {$plugin.tx_solr.solr.path}

	useCurlHttpTransport = 0
  }

  
  templateFile {
	#frequentSearches = EXT:solr/resources/templates/pi_frequentsearches/frequentsearches.htm
	moreLikeThis = EXT:solr/resources/templates/pi_mlt/mlt.htm
	results = typo3conf/ext/mysite/res/template/extensions/results_3.html
	search = typo3conf/ext/mysite/res/template/extensions/mini_search.html
  }

  addDefaultCss = 0
  addDefaultJs = 1

  enableDebugMode = 1

  general {
	dateFormat.date = d.m.Y H:i
  }
  
  index {
	enablePageIndexing = 1
	enableFileIndexing = 1
	
	files {
	  // defines which files to index. Comma separated list of file type suffixes
	  allowedTypes = doc,docx,ppt,pptx,xls,xlsx,odt,ods,odp,txt,pdf,rtf
	}
	
	
	additionalFields {

	}

	  // assigns processing instructions to Solr fields during indexing, Solr field = processing instruction
	fieldProcessingInstructions {
	  changed = timestampToIsoDate
	  created = timestampToIsoDate
	  endtime = timestampToIsoDate
	}

	queue {

	  // mapping tableName.fields.SolrFieldName => TableFieldName (+ cObj processing)

	  pages = 1
	  pages {
	    indexer = tx_solr_indexqueue_PageIndexer
	    indexer {
	      // add options for the indexer here
	    }

	      // only index standard pages
	    additionalWhereClause = doktype = 1 AND no_search = 0

	    fields {
	      sortAuthor_stringS = author
	      sortTitle_stringS  = title
	      sortSubTitle_stringS = subtitle
	    }
	  }

	  tt_news = 1
	  

#        attachments {
#          fields = news_files
#        }
	  
	}
  }
  
  search {
	# TODO: move filter into query{}
	filter =

	targetPage = 476

	initializeWithEmptyQuery = 0
	showResultsOfInitialEmptyQuery = 0
	keepExistingParametersForNewSearches = 0

	query {
	  fields = content^40.0, title^5.0, keywords^2.0, tagsH1^5.0, tagsH2H3^3.0, tagsH4H5H6^2.0, tagsInline^1.0

	  # see http://wiki.apache.org/solr/DisMaxRequestHandler#mm_.28Minimum_.27Should.27_Match.29
	  minimumMatch =

	  # see http://wiki.apache.org/solr/DisMaxRequestHandler#bf_.28Boost_Functions.29
	  boostFunction =

	  # see http://wiki.apache.org/solr/DisMaxQParserPlugin#bq_.28Boost_Query.29
	  boostQuery =

	  // TODO implement multiple filters
#      filter {
#        10 = x:y
#        20 = a:b
#      }
	}

	# TODO make it a top level configuration section
	results {
	  resultsHighlighting = 1
	  resultsHighlighting {
	    highlightFields = title,content
	    fragmentSize = 200

	    wrap = <span class="results-highlight">|</span>
	  }
	  siteHighlighting = 0

	  resultsPerPage = {$plugin.tx_solr.search.results.resultsPerPage}
	  resultsPerPageSwitchOptions = 10, 20, 30, 50

	  # fieldname => processing instruction, available instructions: timestamp, utf8Decode, skip (removes the field from the result)
	  fieldProcessingInstructions {
	    title = utf8Decode
	    content = utf8Decode
	    changed = timestamp
	    created = timestamp
	    indexed = timestamp
	    # TODO rename the skip instruction to remove?!
	    spell = skip
	  }

	  fieldRenderingInstructions {

	    # additional example rendering instruction for the title field
	    title2 = TEXT
	    title2 {
	      field = title
	      case = upper
	      wrap = <span class="title">|</span>
	    }

	    url = CASE
	    url {
	      key.field = type

	      tx_solr_file = TEXT
	      tx_solr_file {
	        typolink {
	          parameter.field = fileRelativePath
	          returnLast = url
	        }
	      }

	      default = TEXT
	      default {
	        field = url
	        htmlSpecialChars = 1
	        htmlSpecialChars.preserveEntities = 1
	      }
	    }

	    link = CASE
	    link {
	      key.field = type

	      tx_solr_file = TEXT
	      tx_solr_file {
	        field = fileName

	        typolink {
	          parameter.field = fileRelativePath
	        }
	      }

	      pages  = TEXT
	      pages {
	        field = title

	        typolink {
	          parameter.field = uid
	        }
	      }

	      default  = TEXT
	      default {
	        field = title

	        typolink {
	          parameter.field = url
	          extTarget =
	        }
	      }
	    }
	    
	    fileReferenceTitle2 = TEXT
	    fileReferenceTitle2.typolink.parameter.field = pid
	    fileReferenceTitle2.field = fileReferenceTitle
	  }
	  
	  pagebrowser {
	    # TODO move to top level templateFile options
	    templateFile = EXT:solr/resources/templates/pi_results/pagebrowser.htm
	  }

	  ignorePageBrowser = 0

	  showDocumentScoreAnalysis = 0

	  markResultTypeBoundaries = 1
	}

	spellchecking = 1
	spellchecking {
	  wrap = |<div class="spelling-suggestions">###LLL:didYouMean### |</div>|
	}

#    contentElevation = 0
#    contentElevation {
#      forceElevation = 1
#    }

	lastSearches = 0
	lastSearches {
	  limit = 10
	  # tracking mode "user" or "global"
	  mode = user
	}

	frequentSearches = 0
	frequentSearches {
	  minSize = 14
	  maxSize = 32
	  limit = 20
	  select {
	    SELECT = keywords as search_term, count(*) as hits
	    FROM = tx_solr_statistics
	    ADD_WHERE = AND num_found != 0
	    GROUP_BY = keywords
	    ORDER_BY = hits DESC, search_term ASC
	    checkRootPageId = 1
	    checkLanguage = 1
	  }

	  # cache lifetime in seconds (default is 86400s = 24h)
	  cacheLifetime = 86400
	}

	sorting = 1
	  sorting {
	  defaultOrder = asc

	  options {
	    
	    relevance {
	      field = relevance
	      label = sorting_relevance
	    }

	    title {
	      field = sortTitle_stringS
	      label = sorting_title
	    }

	    type {
	      field = type
	      label = sorting_type
	    }

	    created {
	      field = created
	      label = sorting_created
	    }
	    
	  }
	}

	# Activer les filtres
	  faceting = 1
	  faceting.singleFacetMode = 1
	  faceting.removeFacetLinkText = @facetText (supprimer)
	  faceting.facets {
	    type {
	    label = Type de contenu
	    keepAllOptionsOnSelection = 1
	    selectingSelectedFacetOptionRemovesFilter = 1
	    renderingInstruction = CASE
	    renderingInstruction {
	      key.field = optionValue
	      
	      pages = TEXT
	      pages.value = Pages
	      
	      tt_news = TEXT
	      tt_news.value = Actualités
	      
	      tx_solr_file = TEXT
	      tx_solr_file.value = Fichiers
	      
	      default = TEXT
	      default.value = Autres
	    }
	    }
	    author >
	  }

  }

  statistics = 0
  statistics {
	  // not implemented yet, might be an option that triggers the query's debug mode (which is on by default for now)
	detailedStatistics = 0
  }

  suggest = 1
  suggest {
	loadJQuery = 0

	numberOfSuggestions = 10
	suggestField = spell
	forceHttps = 0

	stylesheet = EXT:solr/resources/css/jquery-ui/jquery-ui.custom.css

	javaScriptFiles {
	  library = EXT:solr/resources/javascript/jquery-1.4.2.min.js
	  ui      = EXT:solr/resources/javascript/jquery-ui-1.8.9.custom.min.js
	  suggest = EXT:solr/resources/javascript/eid_suggest/suggest.js
	}
  }

  moreLikeThis {

  }

  viewhelpers {
	crop {
	  maxLength = 300
	  cropIndicator = ...
	}
  }

  logging {
	exceptions = 1

	indexing {
	  missingTypo3SearchMarkers = 1
	  indexQueuePageIndexerGetData = 0
	  pageIndexed = 0
	}

	query {
	  filters = 1
	  searchWords = 1
	  queryString = 1
	  rawPost = 1
	  rawGet = 1
	}

	scheduler {
	    // TODO add logging to the optimize task
	  optimize = 0
	}
  }
}

tx_solr.index.queue.tx_solr_indexqueue_item {
  fields {
	crdateS_dateS = changed
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment