How do you exclude individual items from being indexed/searchable by SOLR?

Is it possible to exclude individual items from being indexed/searchable by the SOLR Pro plugin?

https://github.com/jeffcoughlin/farcrysolrpro

That is, I want all files to be indexed/searchable, except for files specifically flagged by the user.

1 Like

Looks like the plugin allows you to add a function contentToIndex to your content type that overrides the default query for indexing

<cfif structKeyExists(oType, "contentToIndex")>
	<!--- run the contentToIndex method for this content type --->
	<cfset stResult.qContentToIndex = oType.contentToIndex() />

The query needs to return objectID, datetimelastupdated columns.

That is correct. More details (and example code) can be found in the online docs here:
http://jeffcoughlin.github.io/farcrysolrpro/documentation.html#filtercontent

For example,

<cffunction name="contentToIndex" access="public" output="false" returntype="query">
  <cfargument name="objectId" type="uuid" required="false" />
  <cfargument name="batchSize" required="false" type="numeric" default="#application.fapi.getConfig(key = "solrserver", name = "batchSize", default = 1000)#" />
  <cfargument name="builtToDate" required="false" type="any" default="" />
  <cfargument name="bGetAllIds" type="boolean" required="false" default="true" hint="If true, returns all records (used for indexRecords() method when comparing DB and Solr records so that Solr knows which ones to delete)." />
  <cfset var qData = "" />
  <cfquery name="qData" datasource="#application.dsn#" maxrows="#arguments.batchSize#">
    select objectID, datetimelastupdated
    from #application.dbowner#myProduct
    where status = 'approved'
      and (publishDate = ''
            or publishDate is null
            or (publishDate != ''
                 and not publishDate is null
                 and publishDate <= getdate()
               )
          )
      and (expirydate >= getdate()
            or expirydate = ''
            or expirydate is null
          )
      and bActive = 1
      <cfif structKeyExists(arguments, "objectId")>
        and objectId = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.objectId#" />
      </cfif>
      <cfif arguments.bGetAllIds is false and arguments.builtToDate neq "" and isDate(arguments.builtToDate)>
        and datetimelastupdated > <cfqueryparam cfsqltype="cf_sql_timestamp" value="#arguments.builtToDate#" />
      </cfif>
      order by datetimelastupdated;
  </cfquery>
  <cfreturn qData />
</cffunction>

Good luck.

2 Likes