首页数据库solr数据库 solr5.5怎么连接oracle数据库

solr数据库 solr5.5怎么连接oracle数据库

编程之家2023-10-22253次浏览

很多朋友对于solr数据库和solr5.5怎么连接oracle数据库不太懂,今天就由小编来为大家分享,希望可以帮助到大家,下面一起来看看吧!

solr数据库 solr5.5怎么连接oracle数据库

solr5.5怎么连接oracle数据库

solr5.5怎么连接oracle数据库

方法如下:

1、

启动Navicat

,连接->oracle,配置如下:连接名随便起

2、Basic连接类型:连接类型有两种,我们先看用Basic的连接方式,此方法适合没有安装Oracle客户端的机器,配置好之后,点连接测试,如果你数据库没有问题,则能连接测试成功。

solr数据库 solr5.5怎么连接oracle数据库

3,TNS连接类型:选择TNS监听连接类型,你首先要安装好oracle客户端,安装完成后,连接数据库时,先配置OCI.dll路径,Navicat->工具>选项>OCI,将oci.dll路径设置成你安装客户端的路径,如本例:D:\app\Administrator\product\11.2.0\client_2\oci.dll,

4,还有一步要做,到连接的Oracle数据库目录下找到tnsnames.ora文件,一般路径在D:\oracle\product\10.2.0\db_1\NETWORK\ADMIN下,将该文件拷贝到你安装的oracle客户端目录下,如D:\app\Administrator\product\11.2.0\client_1\Network\Admin\tnsnames.ora,在连接时就可以直接用TNS方式连接了,程序会自动识别你的网络连接名,如果没有自动识别网络连接名,说明配置的不对,再检查下有说明漏的。

5,配置好之后,点连接测试,如果你数据库没有问题,则能连接测试成功。

如何保证solr跟数据库的数据一致性

可以通过定时任务实现solr与数据库数据的的一致性、比如每天夜里某个时间点、对数据进行更新同步。更新分两种、一种叫增量,是在之前的数据的基础上,将变动的数据进行更新;另一种叫全量更新、是直接删除原来的数据、全部导入新的数据。。。我就知道这些

solr的索引数据可以存放到数据库吗

在solr与tomcat整合文章中,我用的索引库是mycore,现在就以这个为例。

首先要准备jar包:solr-dataimporthandler-4.8.1.jar、solr-dataimporthandler-extras-4.8.1.jar和mysql-connector-java-5.0.7-bin.jar这三个包到solr的tomcat的webapps\solr\WEB-INF\lib下

solr数据库 solr5.5怎么连接oracle数据库

在这个文件夹的conf下配置两个文件,添加一个文件。先配置solrconfig.xml。

在该文件下添加一个新节点。

<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">

<lst name="defaults">

<str name="config">data-config.xml</str>

</lst>

</requestHandler>

在solrconfig.xml的同目录下创建data-config.xml。

配置:

复制代码

<dataConfig>

<dataSource type="JdbcDataSource"

driver="com.mysql.jdbc.Driver"

url="jdbc:mysql://localhost:3306/courseman"

user="root"

password="mysql"/>

<document>

<entity name="student"

query="SELECT* FROM student">

<field column="id" name="id"/>

<field column="name" name="name"/>

<field column="gender" name="gender"/>

<field column="major" name="major"/>

<field column="grade" name="grade"/>

</entity>

</document>

</dataConfig>

复制代码

schemal.xml的配置

复制代码

<?xml version="1.0"?>

<!--

Licensed to the Apache Software Foundation(ASF) under one or more

contributor license agreements. See the NOTICE file distributed with

this work for additional information regarding copyright ownership.

The ASF licenses this file to You under the Apache License, Version 2.0

(the"License"); you may not use this file except in compliance with

the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an"AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.

-->

<schema name="example core one" version="1.1">

<fieldtype name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>

<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>

<fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>

<!-- general-->

<field name="id" type="int" indexed="true" stored="true"/>

<field name="gender" type="string" indexed="true" stored="true"/>

<field name="name" type="string" indexed="true" stored="true"/>

<field name="major" type="string" indexed="true" stored="true"/>

<field name="grade" type="string" indexed="true" stored="true"/>

<field name="_version_" type="long" indexed="true" stored="true"/>

<!-- field to use to determine and enforce document uniqueness.-->

<uniqueKey>id</uniqueKey>

<!-- field for the QueryParser to use when an explicit fieldname is absent-->

<defaultSearchField>name</defaultSearchField>

<!-- SolrQueryParser configuration: defaultOperator="AND|OR"-->

<solrQueryParser defaultOperator="OR"/>

</schema>

复制代码

默认的文件不是这样的,稍微改动了一下。

field的type类型是根据fieldtype的name定义的。class是solr自定义的不能更改。

shcema.xml文件的field字段的属性介绍:

(1)name:字段名称

(2)type:字段类型(此处type不是java类型,而是下面定义的fieldType)

(3)indexed:是否索引看true--solr会对这个字段进行索引,只有经过索引的字段才能被搜索、排序等;false--不索引

(4)stored:是否存储看true--存储,当我们需要在页面显示此字段时,应设为true,否则false。

(5)required:是否必须看true--此字段为必需,如果此字段的内容为空,会报异常;false--不是必需

(6)multiValued:此字段是否可以保存多个值看

(7)omitNorms:是否对此字段进行解析看有时候我们想通过某个字段的完全匹配来查询信息,那么设置 indexed="true"、omitNorms="true"。

(8)default:设置默认值

有这样一个FieldType

<fieldType name="text_general" positionIncrementGap="100">

<analyzer type="index">

<tokenizer/>

<filter ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true"/>

<filter/>

</analyzer>

<analyzer type="query">

<tokenizer/>

<filter ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true"/>

<filter synonyms="synonyms.txt" ignoreCase="true" expand="true"/>

<filter/>

</analyzer>

</fieldType>

属性说明:

(1)name:类型名称,<field>中的type引用的就是这个name

(2)class:solr自定义的类型

(3)<analyzer type="index">定义建立索引时使用的分词器及过滤器

(4)<analyzer type="query">定义搜索时所使用的分词器及过滤器

(5)<tokenizer/>定义分词器

(6)<filter/>定义过滤器

uniqueKey属性

<uniqueKey>id</uniqueKey>

类似于数据表数据的id,solr索引库中最好定义一个用于标示document唯一性的字段,此字段主要用于删除document。

defaultSearchField属性

就是你在做query搜寻时若不指定特定栏位做检索时, Solr就会只查这个栏位.

<defaultSearchField>default</defaultSearchField>

copyField属性

是用来复制你一个栏位里的值到另一栏位用.如你可以将name里的东西copy到major里,这样solr做检索时也会检索到name里的东西.

<copyField source="name" dest="major"/>

现在可以将数据库的数据导入solr了。

点击Execute就可以了。

文章到此结束,如果本次分享的solr数据库和solr5.5怎么连接oracle数据库的问题解决了您的问题,那么我们由衷的感到高兴!

高防御服务器,高防服务器的如何防御联想刀片服务器(联想服务器bmc网络通用设置,方式区别)