1

我可以通过将 solr 分发中的文件夹手动复制到我的网络应用程序中来做到这一点。但我觉得应该有一个巧妙的方法来做到这一点。

4

1 回答 1

0

我可以按照以下步骤进行。

Step-1:在 pom.xml 中添加所需的 jars 依赖项,如下所示。

    <solr.version>4.0.0</solr.version>
    <dependency>
        <groupId>org.apache.solr</groupId>
        <artifactId>solr-core</artifactId>
        <version>${solr.version}</version>
        <exclusions>
            <exclusion>
                <artifactId>slf4j-jdk14</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jcl-over-slf4j</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.solr</groupId>
        <artifactId>solr-solrj</artifactId>
        <version>${solr.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.solr</groupId>
        <artifactId>solr-velocity</artifactId>
        <version>${solr.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.solr</groupId>
        <artifactId>solr-dataimporthandler</artifactId>
        <version>${solr.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.maven.indexer</groupId>
        <artifactId>indexer-core</artifactId>
        <version>${solr.version}</version>
    </dependency>

步骤 2:在 web.xml 中添加以下映射

    <env-entry>
        <env-entry-name>solr/home</env-entry-name>
        <env-entry-value>C:\Sadhana\apache-solr-4.0.0\example\example-DIH\solr</env-entry-value>
        <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>
    <filter>
        <filter-name>SolrRequestFilter</filter-name>
        <filter-class>org.apache.solr.servlet.SolrDispatchFilter</filter-class>
        <init-param>
            <param-name>Context of my webapp</param-name>
            <param-value>2</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>SolrRequestFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <servlet>
        <servlet-name>Zookeeper</servlet-name>
        <servlet-class>org.apache.solr.servlet.ZookeeperInfoServlet</servlet-class>
    </servlet>

    <servlet>
        <servlet-name>LoadAdminUI</servlet-name>
        <servlet-class>org.apache.solr.servlet.LoadAdminUiServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>RedirectOldAdminUI</servlet-name>
        <servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class>
        <init-param>
            <param-name>destination</param-name>
            <param-value>${context}/</param-value>
        </init-param>
    </servlet>

    <servlet>
        <servlet-name>RedirectOldZookeeper</servlet-name>
        <servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class>
        <init-param>
            <param-name>destination</param-name>
            <param-value>${context}/zookeeper</param-value>
        </init-param>
    </servlet>

    <servlet>
        <servlet-name>RedirectLogging</servlet-name>
        <servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class>
        <init-param>
            <param-name>destination</param-name>
            <param-value>${context}/~logging</param-value>
        </init-param>
    </servlet>

    <servlet-mapping>
        <servlet-name>RedirectOldAdminUI</servlet-name>
        <url-pattern>/admin</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>RedirectOldZookeeper</servlet-name>
        <url-pattern>/zookeeper.jsp</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>RedirectLogging</servlet-name>
        <url-pattern>/logging</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>Zookeeper</servlet-name>
        <url-pattern>/zookeeper</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>LoadAdminUI</servlet-name>
        <url-pattern>/admin.html</url-pattern>
    </servlet-mapping>

    <mime-mapping>
        <extension>.xsl</extension>
        <mime-type>application/xslt+xml</mime-type>
    </mime-mapping> 

第 3 步:将 solr 发行版的 solr-webapp 中的以下目录添加到我的 webapp 中。1.css 2.img 3.js 4.tpl 5.admin.html、favicon.ico、Thumbs.db

Step-4:从目录修改以下solr配置 - apache-solr-4.0.0\example\example-DIH\solr 1.solr.xml 2.solrconfig.xml 3.schema.xml 4.db-data-config .xml 步骤 5:重新启动 websphere 并添加 webapp 并使用您的服务器 ipaddress:9080/contextwebapp 访问 solr url 这将打开 solr 的管理页面

于 2012-12-12T19:19:42.840 回答