From f8bebca93fcaf37a7564b066b0f1b6dc1e7a5551 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 02 三月 2021 18:37:08 +0800 Subject: [PATCH] SolrJ升级 --- src/test/java/com/hxh/spring/test/SolrTest.java | 56 ++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/test/java/com/hxh/spring/test/SolrTest.java b/src/test/java/com/hxh/spring/test/SolrTest.java index 1e6780e..bf68088 100644 --- a/src/test/java/com/hxh/spring/test/SolrTest.java +++ b/src/test/java/com/hxh/spring/test/SolrTest.java @@ -1,23 +1,35 @@ package com.hxh.spring.test; +import com.yeshi.buwan.dao.HomeNoticeDao; +import com.yeshi.buwan.domain.HomeNotice; import com.yeshi.buwan.domain.SolrVideo; import com.yeshi.buwan.domain.VideoInfo; +import com.yeshi.buwan.dto.search.SolrResultDTO; +import com.yeshi.buwan.dto.search.SolrVideoSearchFilter; import com.yeshi.buwan.iqiyi.util.IqiyiUtil; import com.yeshi.buwan.service.imp.VideoInfoService; import com.yeshi.buwan.service.manager.SolrAlbumDataManager; +import org.apache.http.auth.Credentials; +import org.apache.solr.client.solrj.SolrClient; +import org.apache.solr.client.solrj.SolrRequest; +import org.apache.solr.client.solrj.SolrServerException; +import org.apache.solr.common.util.NamedList; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.data.solr.server.support.HttpSolrClientFactory; +import org.springframework.data.solr.server.support.HttpSolrClientFactoryBean; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import javax.annotation.Resource; +import java.io.IOException; import java.util.List; -//@RunWith(SpringJUnit4ClassRunner.class) -//@ContextConfiguration(locations = {"classpath:spring.xml"}) -//@WebAppConfiguration +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = {"classpath:spring.xml"}) +@WebAppConfiguration public class SolrTest { @Resource @@ -26,22 +38,42 @@ @Resource private VideoInfoService videoInfoService; + @Resource + private HomeNoticeDao homeNoticeDao; + @Test public void test1() { - List<SolrVideo> list = solrDataManager.findByKey("鑻�", 1, 150, 1); - System.out.println(list.size()); - list = solrDataManager.findByKey("鑻�", 0, 150, 1); - System.out.println(list.size()); - list = solrDataManager.findByKey("鑻�", 1, 151, 1); - System.out.println(list.size()); + SolrVideoSearchFilter filter = new SolrVideoSearchFilter(); + filter.setKey(""); + filter.setVideoType(null); + filter.setContentType(1); +// filter.setResourceIds(new String[]{"24"}); + + SolrResultDTO dto = solrDataManager.find(filter, 1, 10); + System.out.println(dto); } @Test - public void addSolrAlbum(){ -// solrDataManager.saveOrUpdate(videoInfoService.getVideoInfo("7967903")); - System.out.println( IqiyiUtil.getVPicture("http://pic3.iqiyipic.com/image/20200817/a4/f5/a_100390080_m_601_m15.jpg")); + public void addSolrAlbum() { + solrDataManager.syncAlbum("8224447"); + SolrClient solrClient=new SolrClient() { + @Override + public NamedList<Object> request(SolrRequest solrRequest, String s) throws SolrServerException, IOException { + return null; + } + + @Override + public void close() throws IOException { + + } + }; + Credentials credentials=new Credentials(); + HttpSolrClientFactory factory=new HttpSolrClientFactory(); } + + + } -- Gitblit v1.8.0