Solr Autocomplete: Multiple dictionarys with field and file dictionary - dictionary

I´m trying to build an solr suggester with a solr 4.6.0 and an tomcat7. The suggester should use multiple fields from the solr(suName,suFea) and a file based dictionary(suList). The suggest with multiple fields is working. But the combination from field and a file dictionary doesn,t work because the analyzer needs the same type from every dictionary. I tried to fix the issue with multiple components. The result was an nullpointer.
Is there any option to build such a situation?
Thanks.
solrconfig.xml:
<searchComponent name="suggest" class="solr.SpellCheckComponent">
<lst name="spellchecker">
<str name="name">suFea</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.fst.WFSTLookupFactory</str>
<str name="suggestAnalyzerFieldType">lowercase</str>
<str name="field">features</str>
<str name="buildOnCommit">true</str>
</lst>
<lst name="spellchecker">
<str name="name">suName</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.fst.WFSTLookupFactory</str>
<str name="suggestAnalyzerFieldType">lowercase</str>
<str name="field">name</str>
<!--<float name="threshold">0.005</float>-->
<str name="buildOnCommit">true</str>
</lst>
</searchComponent>
<searchComponent name="fileSuggest" class="solr.SpellCheckComponent">
<lst name="spellchecker">
<str name="name">suList</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.fst.WFSTLookupFactory</str>
<str name="suggestAnalyzerFieldType">lowercase</str>
<str name="sourceLocation">./suggester/dict.txt</str>
<str name="fieldType">string</str>
<!--<float name="threshold">0.005</float>-->
<str name="buildOnCommit">true</str>
</lst>
</searchComponent>
<requestHandler name="/suggest" class="solr.SearchHandler">
<lst name="defaults">
<str name="echoParams">explicit</str>
<str name="spellcheck">true</str>
<str name="spellcheck.dictionary">suName</str>
<str name="spellcheck.dictionary">suFea</str>
<str name="spellcheck.dictionary">suList</str>
<str name="spellcheck.onlyMorePopular">true</str>
<str name="spellcheck.collate">false</str>
<str name="spellcheck.count">25</str>
</lst>
<arr name="components" >
<str>suggest</str>
<str>fileSuggest</str>
</arr>
</requestHandler>
Error:
java.lang.NullPointerException at org.apache.solr.spelling.ConjunctionSolrSpellChecker.addChecker(ConjunctionSolrSpellChecker.java:58) at
org.apache.solr.handler.component.SpellCheckComponent.getSpellChecker(SpellCheckComponent.java:505) at
org.apache.solr.handler.component.SpellCheckComponent.prepare(SpellCheckComponent.java:123) at
org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:187) at
org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135) at org.apache.solr.core.SolrCore.execute(SolrCore.java:1859) at
org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:710) at
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:413) at
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:197) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079) at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745)

i am using solr 6.2.0 version
and clearly multiple suggester work for me solrconfig.xml config as follow and managed-schema.xml config below it. if u want i can share java code here too
************************** solrconfig.xml CONFIG **************************
<searchComponent class="solr.SuggestComponent" name="suggest">
<lst name="suggester">
<str name="name">ilsuggester</str>
<str name="lookupImpl">FuzzyLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">IL_ADI</str>
<str name="suggestAnalyzerFieldType">textgen</str>
<str name="storeDir">suggest_fuzzy_doc_expr_dict</str>
<str name="buildOnStartup">false</str>
<str name="buildOnCommit">false</str>
</lst>
<lst name="suggester">
<str name="name">ilcesuggester</str>
<str name="lookupImpl">FuzzyLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">ILCE_ADI</str>
<str name="suggestAnalyzerFieldType">textgen</str>
<str name="indexPath">suggestions/ilcesuggester</str>
<str name="storeDir">suggest_fuzzy_doc_expr_dict</str>
<str name="buildOnStartup">false</str>
<str name="buildOnCommit">false</str>
</lst>
<lst name="suggester">
<str name="name">mahallesuggester</str>
<str name="lookupImpl">FuzzyLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">MAHALLE_ADI</str>
<str name="suggestAnalyzerFieldType">textgen</str>
<str name="indexPath">suggestions/mahallesuggester</str>
<str name="storeDir">suggest_fuzzy_doc_expr_dict</str>
<str name="preserveSep">true</str>
<str name="preservePositionIncrements">true</str>
<str name="exactMatchFirst">true</str>
<float name="threshold">0.005</float>
<str name="buildOnStartup">false</str>
<str name="buildOnCommit">false</str>
</lst>
<lst name="suggester">
<str name="name">sokaksuggester</str>
<str name="lookupImpl">FuzzyLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">SOKAK</str>
<str name="suggestAnalyzerFieldType">textgen</str>
<str name="indexPath">suggestions/sokaksuggester</str>
<str name="storeDir">suggest_fuzzy_doc_expr_dict</str>
<str name="preserveSep">true</str>
<str name="preservePositionIncrements">true</str>
<str name="buildOnStartup">false</str>
<str name="buildOnCommit">false</str>
</lst>
<lst name="suggester">
<str name="name">caddesuggester</str>
<str name="lookupImpl">FuzzyLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">CADDE</str>
<str name="suggestAnalyzerFieldType">textgen</str>
<str name="indexPath">suggestions/caddesuggester</str>
<str name="storeDir">suggest_fuzzy_doc_expr_dict</str>
<str name="preserveSep">true</str>
<str name="preservePositionIncrements">true</str>
<str name="buildOnStartup">false</str>
<str name="buildOnCommit">false</str>
</lst>
<lst name="suggester">
<str name="name">yolsuggester</str>
<str name="lookupImpl">FuzzyLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">YOL_ADI</str>
<str name="suggestAnalyzerFieldType">textgen</str>
<str name="indexPath">suggestions/yolsuggester</str>
<str name="storeDir">suggest_fuzzy_doc_expr_dict</str>
<str name="preserveSep">true</str>
<str name="preservePositionIncrements">true</str>
<str name="exactMatchFirst">true</str>
<float name="threshold">0.005</float>
<str name="buildOnStartup">false</str>
<str name="buildOnCommit">false</str>
</lst>
<lst name="suggester">
<str name="name">kapinosuggester</str>
<str name="lookupImpl">FuzzyLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">KAPI_NO</str>
<str name="suggestAnalyzerFieldType">textgen</str>
<str name="indexPath">suggestions/kapinosuggester</str>
<str name="storeDir">suggest_fuzzy_doc_expr_dict</str>
<str name="preserveSep">true</str>
<str name="preservePositionIncrements">true</str>
<str name="exactMatchFirst">true</str>
<float name="threshold">0.005</float>
<str name="buildOnStartup">false</str>
<str name="buildOnCommit">false</str>
</lst>
<lst name="suggester">
<str name="name">kapiadisuggester</str>
<str name="lookupImpl">FuzzyLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">KAPI_ADI</str>
<str name="suggestAnalyzerFieldType">textgen</str>
<str name="indexPath">suggestions/kapiadisuggester</str>
<str name="storeDir">suggest_fuzzy_doc_expr_dict</str>
<str name="preserveSep">true</str>
<str name="preservePositionIncrements">true</str>
<str name="exactMatchFirst">true</str>
<float name="threshold">0.005</float>
<str name="buildOnStartup">false</str>
<str name="buildOnCommit">false</str>
</lst>
</searchComponent>
<requestHandler class="solr.SearchHandler" name="/suggest">
<lst name="defaults">
<str name="spellcheck">true</str>
<str name="suggest">true</str>
<str name="suggest.dictionary">ilsuggester</str>
<str name="suggest.dictionary">ilcesuggester</str>
<str name="suggest.dictionary">mahallesuggester</str>
<str name="suggest.dictionary">sokaksuggester</str>
<str name="suggest.dictionary">caddesuggester</str>
<str name="suggest.dictionary">yolsuggester</str>
<str name="suggest.dictionary">kapinosuggester</str>
<str name="suggest.dictionary">kapiadisuggester</str>
<str name="spellcheck.count">10</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
<field name="CADDE" type="textgen" omitNorms="true" omitTermFreqAndPositions="true" multiValued="true" indexed="true" stored="true"/>
<field name="ILCE_ADI" type="text_general" omitNorms="true" omitTermFreqAndPositions="true" multiValued="true" indexed="true" stored="true"/>
<field name="IL_ADI" type="text_general" omitNorms="true" omitTermFreqAndPositions="true" multiValued="true" indexed="true" stored="true"/>
<field name="KAPI_ADI" type="textgen" omitNorms="true" omitTermFreqAndPositions="true" multiValued="true" indexed="true" stored="true"/>
<field name="MAHALLE_ADI" type="textgen" omitNorms="true" omitTermFreqAndPositions="true" multiValued="true" indexed="true" stored="true"/>
<field name="SOKAK" type="textgen" omitNorms="true" omitTermFreqAndPositions="true" multiValued="true" indexed="true" stored="true"/>
<field name="YOL_ADI" type="textgen" omitNorms="true" omitTermFreqAndPositions="true" multiValued="true" indexed="true" stored="true"/>
<fieldType name="textgen" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="0"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="stopwords.txt"
/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="0"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>

Related

Getting phrases instead of words using Solr autosuggest

I am getting whole phrase instead of getting words on implementing
suggester in solr.
The configuration is like this
<searchComponent name="suggest"
class="solr.SuggestComponent">
 
<lst name="spellchecker">
<str name="name">indexSuggester</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.fst.FSTLookupFactory</str>
<str name="distanceMeasure">org.apache.lucene.search.spell.JaroWinklerDistance</str>
<str name="field">title_txt</str>
<str name="suggestAnalyzerFieldType">textSuggest</str>
<str name="accuracy">0.7</str>
<float name="thresholdTokenFrequency">.0001</float>
</lst>
</searchComponent>
<requestHandler name="/suggest"
class="solr.SearchHandler" startup="lazy">
 
<lst name="defaults">
<str name="suggest">true</str>
<str name="suggest.count">10</str>
<str name="suggest.dictionary">indexSuggester</str>
 
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
<fieldType class="solr.TextField" name="textSuggest"
positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory" />
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.ShingleFilterFactory" minShingleSize="2"
maxShingleSize="5" />
</analyzer>
<field name="title_txt" type="textSuggest" indexed="true"
stored="true" />

SOLR: Document is missing mandatory uniqueKey field: id

I have just started with the solr-6.5.1, trying to import data from Oracle DB.
My data does not have any Unique ID, searched through various forums and found out that using class="solr.UUIDUpdateProcessorFactory" this can be resolved. but stil getting the same error. below is the snippet of my managed-schema and solrconfig.xml.
solrconfig.xml
<requestHandler name="/update" class="solr.UpdateRequestHandler">
<lst name="defaults">
<str name="update.chain">uuid</str>
</lst>
</requestHandler>
<updateRequestProcessorChain name="uuid">
<processor class="solr.UUIDUpdateProcessorFactory">
<str name="fieldName">id</str>
</processor>
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>
managed-schema
<field name="id" type="uuid" indexed="true" stored="true" required="true" />
<field name="SERVICEACCOUNTNUMBER" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="USERNAME" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="NAME" type="string" indexed="true" stored="true" multiValued="false" />
<field name="TRANSACTION_DATE" type="date" indexed="true" stored="true" />
<field name="PROCESSSTATUS" type="string" indexed="true" stored="true" />
<field name="RECHARGE_MODE" type="string" indexed="true" stored="true" />
<field name="PROCESSRECHARGEREQUESTNO" type="string" indexed="true" stored="true" />
<field name="PACKAGE_ID" type="string" indexed="true" stored="true" />
<field name="PACKAGENAME" type="string" indexed="true" stored="true" />
<field name="AMOUNT" type="int" indexed="true" stored="true" multiValued="true" />
<field name="CREDITDOCUMENTNUMBER" type="string" indexed="true" stored="true" multiValued="true" />
<field name="DEBITDOCUMENTNUMBER" type="string" indexed="true" stored="true" />
<field name="SERVICE_TYPE" type="string" indexed="true" stored="true" multiValued="true" />
Please help
answer credits to post solr uuid with error document is missing mandatory uniquekey field id
updated the solrconfig.xml to
<requestHandler name="/dataimport" class="solr.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
<str name="update.chain">uuid</str>
</lst>
</requestHandler>
<updateRequestProcessorChain name="uuid">
<processor class="solr.UUIDUpdateProcessorFactory">
<str name="fieldName">id</str>
</processor>
<processor class="solr.RunUpdateProcessorFactory"/>
</updateRequestProcessorChain>

search results displayed without snippets solr drupal

Hi,
I have a drupal 7 , apache solr integration module with solr attachments module. I never got that notice before but i am puzzled why the search snippets are not getting displayed. Looked at the code mentioned in the notice and did a print_r($snippets) and found that snippets where in the variable and just not getting displayed in the search results. what could be the reason for this ?
solrconfig.xml
<requestHandler name="drupal" class="solr.SearchHandler" default="true">
<lst name="defaults">
<str name="defType">dismax</str>
<str name="echoParams">explicit</str>
<bool name="omitHeader">true</bool>
<float name="tie">0.01</float>
<str name="pf">
content^2.0
</str>
<int name="ps">15</int>
<!-- Abort any searches longer than 4 seconds -->
<!-- <int name="timeAllowed">4000</int> -->
<str name="mm">1</str>
<str name="q.alt">*:*</str>
<!-- example highlighter config, enable per-query with hl=true -->
<str name="hl">true</str>
<str name="hl.fl">content</str>
<int name="hl.snippets">1</int>
<str name="hl.mergeContiguous">true</str>
<!-- instructs Solr to return the field itself if no query terms are
found -->
<str name="f.content.hl.alternateField">teaser</str>
<str name="f.content.hl.maxAlternateFieldLength">256</str>
<!-- JS: I wasn't getting good results here... I'm turning off for now
because I was getting periods (.) by themselves at the beginning of
snippets and don't feel like debugging anymore. Without the regex is
faster too -->
<!--<str name="f.content.hl.fragmenter">regex</str>--> <!-- defined below -->
<!-- By default, don't spell check -->
<str name="spellcheck">false</str>
<!-- Defaults for the spell checker when used -->
<str name="spellcheck.onlyMorePopular">false</str>
<str name="spellcheck.extendedResults">false</str>
<!-- The number of suggestions to return -->
<str name="spellcheck.count">1</str>
</lst>
<arr name="last-components">
<str>spellcheck</str>
</arr>
</requestHandler>
This is the code from the notice which is in the apachesolr_attachments.module
enter code here
function theme_apachesolr_search_snippets__file($vars) {
$doc = $vars['doc'];
$snippets = $vars['snippets'];
$parent_entity_links = array();
// Retrieve our parent entities. They have been saved as
// a small serialized entity
foreach ($doc->zm_parent_entity as $parent_entity_encoded) {
$parent_entity = (object) drupal_json_decode($parent_entity_encoded);
$parent_entity_uri = entity_uri($parent_entity->entity_type, $parent_entity);
$parent_entity_uri['options']['absolute'] = TRUE;
$parent_label = entity_label($parent_entity->entity_type, $parent_entity);
$parent_entity_links[] = l($parent_label, $parent_entity_uri['path'], $parent_entity_uri['options']);
}
if (module_exists('file')) {
$file_type = t('!icon #filemime', array('#filemime' => $doc->ss_filemime, '!icon' => theme('file_icon', array('file' => (object) array('filemime' => $doc->ss_filemime)))));
}
else {
$file_type = t('#filemime', array('#filemime' => $doc->ss_filemime));
}
//print_r($snippets);echo "\n";
return implode(' ... ', $snippets) . '<span>' . $file_type . ' <em>attached to:</em>' . implode(', ', $parent_entity_links) . '</span>';
}
schema.xml
<field name="id" type="string" indexed="true" stored="true" required="true" />
<field name="name" type="string" stored="true" indexed="true"/>
<!-- entity_id is the numeric object ID, e.g. Node ID, File ID -->
<field name="entity_id" type="long" indexed="true" stored="true" />
<!-- entity_type is 'node', 'file', 'user', or some other Drupal object type -->
<field name="entity_type" type="string" indexed="true" stored="true" />
<!-- bundle is a node type, or as appropriate for other entity types -->
<field name="bundle" type="string" indexed="true" stored="true"/>
<field name="bundle_name" type="string" indexed="true" stored="true"/>
<field name="text" type="text" stored="true" indexed="true"/>
<field name="site" type="string" indexed="true" stored="true"/>
<field name="hash" type="string" indexed="true" stored="true"/>
<field name="url" type="string" indexed="true" stored="true"/>
<!-- label is the default field for a human-readable string for this entity (e.g. the title of a node) -->
<field name="label" type="text" indexed="true" stored="true" termVectors="true" omitNorms="true"/>
<!-- The string version of the title is used for sorting -->
<copyField source="label" dest="sort_label"/>
<!-- content is the default field for full text search - dump crap here -->
<field name="content" type="text" indexed="true" stored="true" termVectors="true"/>
<field name="content_type" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="teaser" type="text" indexed="false" stored="true"/>
<field name="language" type="text_en" stored="true" indexed="true"/>
<field name="path" type="string" indexed="true" stored="true"/>
<field name="path_alias" type="text" indexed="true" stored="true" termVectors="true" omitNorms="true"/>
<field name="created" type="string" indexed="true" stored="true" termVectors="true"/>
<field name="Question" type="text" indexed="true" stored="true" termVectors="true"/>
<field name="Response" type="text" indexed="true" stored="true" termVectors="true"/>
<field name="Module" type="text" indexed="true" stored="true" termVectors="true"/>
<field name="Meets" type="text" indexed="true" stored="true" termVectors="true"/>
<field name="cat" type="string" indexed="true" stored="true" termVectors="true"/>
Any suggestions to get rid of the notice as well as to display the snippets ?
I replaced return implode(' ... ', $snippets) with return implode(' ... ', $snippets['content']) and it worked for me.
I can't guarantee that problems cannot arise.
Worth a try anyway.

unknown field solr drupal module

Indexing failed on one of the following entity ids: node/2
"400" Status: ERROR: [doc=l8febs/node/2] unknown field 'language': ERROR: [doc=l8febs/node/2] unknown field 'language'
Error 400 ERROR: [doc=l8febs/node/2] unknown field 'language'
HTTP ERROR 400
Problem accessing /solr/update. Reason:
ERROR: [doc=l8febs/node/2] unknown field 'language'Powered by Jetty://
I am wondering what is the problem. My schema.xml file does not have a field named language, will that solve the problem? I have never needed this?
schema.xml
<field name="id" type="string" indexed="true" stored="true" required="true" />
<field name="name" type="string" stored="true" indexed="true"/>
<!-- entity_id is the numeric object ID, e.g. Node ID, File ID -->
<field name="entity_id" type="long" indexed="true" stored="true" />
<!-- entity_type is 'node', 'file', 'user', or some other Drupal object type -->
<field name="entity_type" type="string" indexed="true" stored="true" required="true" />
<!-- bundle is a node type, or as appropriate for other entity types -->
<field name="bundle" type="string" indexed="true" stored="true"/>
<field name="bundle_name" type="string" indexed="true" stored="true"/>
<field name="text" type="text" stored="true" indexed="true"/>
<field name="site" type="string" indexed="true" stored="true"/>
<field name="hash" type="string" indexed="true" stored="true"/>
<field name="url" type="string" indexed="true" stored="true"/>
<!-- label is the default field for a human-readable string for this entity (e.g. the title of a node) -->
<field name="label" type="text" indexed="true" stored="true" termVectors="true" omitNorms="true"/>
<!-- The string version of the title is used for sorting -->
<copyField source="label" dest="sort_label"/>
<!-- content is the default field for full text search - dump crap here -->
<field name="content" type="text" indexed="true" stored="true" termVectors="true"/>
<field name="teaser" type="text" indexed="false" stored="true"/>
<field name="language" type="text_en" stored="true" indexed="true"/>
<field name="path" type="string" indexed="true" stored="true"/>
<field name="path_alias" type="text" indexed="true" stored="true" termVectors="true" omitNorms="true"/>
The apache solr 3.2 and the schema.xml is from the apaache solr integration module for drupal 7
solrconfig.xml is
<requestHandler name="dismax" class="solr.SearchHandler">
<lst name="defaults">
<str name="defType">dismax</str>
<str name="echoParams">explicit</str>
<bool name="omitHeader">true</bool>
</lst>
</requestHandler>
<!-- Note how you can register the same handler multiple times with
different names (and different init parameters)
-->
<requestHandler name="drupal" class="solr.SearchHandler">
<lst name="defaults">
<str name="defType">dismax</str>
<str name="echoParams">explicit</str>
<bool name="omitHeader">true</bool>
<float name="tie">0.01</float>
<str name="pf">
content^2.0
</str>
<int name="ps">15</int>
<!-- Abort any searches longer than 4 seconds -->
<!-- <int name="timeAllowed">4000</int> -->
<str name="mm">1</str>
<str name="q.alt">*:*</str>
<!-- example highlighter config, enable per-query with hl=true -->
<str name="hl">true</str>
<str name="hl.fl">content</str>
<int name="hl.snippets">3</int>
<str name="hl.mergeContiguous">true</str>
<!-- instructs Solr to return the field itself if no query terms are
found -->
<str name="f.content.hl.alternateField">teaser</str>
<str name="f.content.hl.maxAlternateFieldLength">256</str>
<!-- JS: I wasn't getting good results here... I'm turning off for now
because I was getting periods (.) by themselves at the beginning of
snippets and don't feel like debugging anymore. Without the regex is
faster too -->
<!--<str name="f.content.hl.fragmenter">regex</str>--> <!-- defined below -->
<!-- By default, don't spell check -->
<str name="spellcheck">false</str>
<!-- Defaults for the spell checker when used -->
<str name="spellcheck.onlyMorePopular">true</str>
<str name="spellcheck.extendedResults">false</str>
<!-- The number of suggestions to return -->
<str name="spellcheck.count">1</str>
</lst>
<arr name="last-components">
<str>spellcheck</str>
</arr>
</requestHandler>
If you don't want fields, you can simple ignore the fields to prevent them causing error. e.g.
Define a ignored field type :-
<fieldtype name="ignored" stored="false" indexed="false" class="solr.StrField" />
And define a Dynamic field :-
<dynamicField name="some regex to capture all unwanted fields" type="ignored"/>

Solr query for items with field:value or no value for field at all

I'm trying to query Solr for entries that either have a certain value in a field OR no value for the field. The negated field value works when used by itself but causes the query to return no results when combined with anything else. Below is a response with debugQuery enabled. The config file I use can be found here.
<?xml version="1.0"?>
<response>
<responseHeader>
<status>0</status>
<QTime>3</QTime>
<lst name="params">
<str name="facet">true</str>
<str name="sort">sort_title asc</str>
<str name="fl">id,nid,url,uid</str>
<str name="debugQuery">true</str>
<str name="facet.mincount">1</str>
<str name="facet.sort">true</str>
<str name="start">0</str>
<str name="bf">recip(rord(created),4.000000,239,239)^200.000000</str>
<arr name="fq">
<str>NOT type:article</str>
<str>NOT type:insect</str>
<str>NOT type:news</str>
<str>NOT type:plant</str>
<str>im_cck_field_affected_plants:(20 OR -[* TO *])</str>
<str>entity:node</str>
</arr>
<str name="version">1.2</str>
<str name="rows">16</str>
</lst>
</responseHeader>
<result name="response" numFound="0" start="0"/>
<lst name="facet_counts">
<lst name="facet_queries"/>
<lst name="facet_fields"/>
<lst name="facet_dates"/>
</lst>
<lst name="debug">
<null name="rawquerystring"/>
<null name="querystring"/>
<str name="parsedquery">+MatchAllDocsQuery(*:*) FunctionQuery((239.0/(4.0*float(top(rord(created)))+239.0))^200.0)</str>
<str name="parsedquery_toString">+*:* (239.0/(4.0*float(top(rord(created)))+239.0))^200.0</str>
<lst name="explain"/>
<str name="QParser">DisMaxQParser</str>
<str name="altquerystring">org.apache.lucene.search.MatchAllDocsQuery:*:*</str>
<arr name="boostfuncs">
<str>recip(rord(created),4.000000,239,239)^200.000000</str>
</arr>
<arr name="filter_queries">
<str>NOT type:article</str>
<str>NOT type:insect</str>
<str>NOT type:news</str>
<str>NOT type:plant</str>
<str>im_cck_field_affected_plants:(20 OR -[* TO *])</str>
<str>entity:node</str>
</arr>
<arr name="parsed_filter_queries">
<str>-type:article</str>
<str>-type:insect</str>
<str>-type:news</str>
<str>-type:plant</str>
<str>im_cck_field_affected_plants:20 -im_cck_field_affected_plants:[* TO *]</str>
<str>entity:node</str>
</arr>
<lst name="timing">
<double name="time">3.0</double>
<lst name="prepare">
<double name="time">3.0</double>
<lst name="org.apache.solr.handler.component.QueryComponent">
<double name="time">2.0</double>
</lst>
<lst name="org.apache.solr.handler.component.FacetComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.MoreLikeThisComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.HighlightComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.StatsComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.SpellCheckComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.DebugComponent">
<double name="time">0.0</double>
</lst>
</lst>
<lst name="process">
<double name="time">0.0</double>
<lst name="org.apache.solr.handler.component.QueryComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.FacetComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.MoreLikeThisComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.HighlightComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.StatsComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.SpellCheckComponent">
<double name="time">0.0</double>
</lst>
<lst name="org.apache.solr.handler.component.DebugComponent">
<double name="time">0.0</double>
</lst>
</lst>
</lst>
</lst>
</response>
Any help would be appreciated.
Finally phrased the question well enough to find an answer through Google.
http://osdir.com/ml/solr-user.lucene.apache.org/2009-03/msg00480.html
OR NOT queries can be written as, using my case as an example:
im_cck_field_affected_plants:20 OR (*:* -im_cck_field_affected_plants:[* TO *])

Resources