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>
Related
Solr Version : 5.0
So I am working on Solr for first time, and really not understand perfectly. Here what I did :-
I have created a core named - search
Then my schema.xml file has follwoing code :
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="simple" version="1.5">
<types>
<fieldtype name='string' class='solr.StrField' />
<fieldtype name='long' class='solr.TrieLongField' />
</types>
<fields>
<field name='id' type='int' required='true' indexed="true"/>
<field name='name' type='text' required='true' indexed="true"/>
</fields>
<uniqueKey>id</uniqueKey>
<defaultSearchField>fullText</defaultSearchField>
<solrQueryParser defaultOperator='OR' />
</schema>
solrconfig.xml :
<?xml version='1.0' encoding='UTF-8' ?>
<config>
<luceneMatchVersion>5.0.0</luceneMatchVersion>
<lib dir="../../../../dist/" regex="solr-dataimporthandler-.*\.jar" />
<requestHandler name="standard" class="solr.StandardRequestHandler" default='true' />
<requestHandler name="/update" class="solr.UpdateRequestHandler" />
<requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">db-data-config.xml</str>
</lst>
</requestHandler>
<admin>
<defaultQuery>*:*</defaultQuery>
</admin>
</config>
db-data-config.xml :
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/solr"
user="root"
password="" />
<document>
<entity name="users" query="select id,name from users;" />
</document>
</dataConfig>
I have created a database on PHPmyadmin please find below SG :
when I clicked query on solr panel then it shows empty why ?
Can anyone help me on this, as I am new to solr search. What I am doing wrong ?
I dont see a field named "fulltext" in schema.xml but why its defined as the default search
<defaultSearchField>fullText</defaultSearchField>
change it
<defaultSearchField>name</defaultSearchField>
mention the fields in the data config xml
<field column="ID" name="id" />
<field column="NAME" name="name" />
your data-config should look alike
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/solr"
user="root"
password="" />
<document>
<entity name="users" query="select id,name from users">
<field column="ID" name="id" />
<field column="NAME" name="name" />
</entity>
</document>
</dataConfig>
add it as in schema.xml
<types>
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
</types>
<fields>
<field name='id' type='int' required='true' indexed="true" stored="true"/>
<field name='name' type='string' required='true' indexed="true" stored="true"/>
<fields>
Make the changes in your db-data-config.xml similar to what i have done
<entity name="city_masters" pk="city_id" query="SELECT delete_status as
city_masters_delete_status,city_id,country_id,city_name,city_updated from
city_masters>
<field column="city_id" name="id"/>
<field column="city_name" name="city_name" indexed="true" stored="true" />
<field column="country_id" name="country_id" indexed="true" stored="true" />
<field column="city_masters_delete_status" name="city_masters_delete_status"
indexed="true" stored="true" />
</entity>
You missed out the field column part.Add them like i have done for my code and it should work.If still doesnt work let me know
i have Banner and Group entities with xml configs
Banner.xml
<mapped-superclass name="Banner" table="luc_banners"
repository-class="BannerRepository">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
<field name="path" column="path" type="string" nullable="true" />
<field name="link" column="link" type="string" nullable="true" />
<field name="position" column="position" type="string" nullable="true" />
<field name="groupId" column="group_id" type="integer" />
<many-to-one field="group" target-entity="Group" inversed-by="banners">
<join-column name="group_id" referenced-column-name="id" nullable="false" on-delete="CASCADE" />
</many-to-one>
</mapped-superclass>
Group.xml
<mapped-superclass name="Group" table="luc_banners_groups" repository-class="GroupRepository">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
<field name="name" column="group_name" type="string" nullable="true" />
<field name="type" column="group_type" type="string" nullable="true" />
<field name="status" column="group_status" type="string" nullable="true" />
<field name="order" column="group_order" type="integer" nullable="true" />
<one-to-many field="banners" target-entity="Banners" mapped-by="group">
<cascade>
<cascade-all />
</cascade>
</one-to-many>
</mapped-superclass>
when trying to get banners form group object i get empty array, and Profiler shows this sql SELECT l0_.group_name AS group_name0, l0_.id AS id4 FROM luc_banners_groups l0_ WHERE l0_.group_status = ? and show not valid entity with this error Banner - The association Banner#group refers to the inverse side field Group#banners which does not exist.
Can you help me with this thing ?
remove <field name="groupId" column="group_id" type="integer" /> from Banner.xml, I think it's overriding the second one..
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.
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"/>
I'm trying to update my doctrine schema with the command:
php app/console doctrine:schema:update --force
I'm getting this error:
[Doctrine\DBAL\DBALException]
Unknown column type requested.
I'm getting this error since I've updated the xml mapping of the user entity in the Sonata UserBundle like this:
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Application\Sonata\UserBundle\Entity\User" table="fos_user_user" repository-class="Application\Sonata\UserBundle\Repository\UserRepository">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
<field name="name" type="string" length="50" />
<field name="birthdate" type="date" />
<field name="natRanking" type="string" length="10" />
<field name="interNatRanking" type="string" length="10" nullable="true" />
<field name="natDoublesRanking" type="string" length="10" />
<field name="interNatDoublesRanking" type="string" length="10" nullable="true" />
<field name="doublesPartner" type="string" length="50" nullable="true" />
<field name="nationality" type="string" length="50" />
<field name="fileName" type="string" length="255" nullable="true" />
<field name="path" type="string" length="255" nullable="true" />
<field name="file" />
<many-to-many field="teams" target-entity="Tennisconnect\DashboardBundle\Entity\Team" mapped-by="players">
<join-table name="team_user">
<join-columns>
<join-column name="team_id" referenced-column-name="id"/>
</join-columns>
<inverse-join-columns>
<join-column name="user_id" referenced-column-name="id"/>
</inverse-join-columns>
</join-table>
</many-to-many>
<one-to-many field="my_friends" target-entity="Friend" mapped-by="friends_of_mine" />
<one-to-many field="friended_me" target-entity="Friend" mapped-by="friends_with_me" />
</entity>
Is the type of the field "file" missing?