国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

ES實戰(zhàn) | 黑馬旅游案例

這篇具有很好參考價值的文章主要介紹了ES實戰(zhàn) | 黑馬旅游案例。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

關(guān)鍵詞搜索

ES實戰(zhàn) | 黑馬旅游案例

需求:根據(jù)文字搜索,也可以選擇標(biāo)簽搜索

思路:用bool查詢,先根據(jù)關(guān)鍵詞查詢?nèi)?,再根?jù)標(biāo)簽過濾。

public class HotelService extends ServiceImpl<HotelMapper, Hotel> implements IHotelService {
    @Autowired
    private RestHighLevelClient client;
    @Override
    public PageResult search(RequestParams params) throws IOException {
        SearchRequest request = new SearchRequest("hotel");
//        關(guān)鍵字搜索
        QueryBuilder query = buildBasicQuery(params);
        request.source().query(query);
        
        SearchResponse response = client.search(request, RequestOptions.DEFAULT);
        return extracted(response);
    }

    private static QueryBuilder buildBasicQuery(RequestParams params) {
        String key  = params.getKey();
        BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
//        query
//        關(guān)鍵字搜索
        if ("".equals(key) || key==null){
            boolQuery.must(QueryBuilders.matchAllQuery());
        }else {
            boolQuery.must(QueryBuilders.matchQuery("all",key));
        }
//        過濾條件
        if (params.getMinPrice()!=null && params.getMaxPrice()!=null){
            boolQuery.filter(QueryBuilders.rangeQuery("price").gte(params.getMinPrice()).lte(params.getMaxPrice()));
        }
        if (!("".equals(params.getCity()) || params.getCity()==null)){
            boolQuery.filter(QueryBuilders.termQuery("city", params.getCity()));
        }
        if (!("".equals(params.getBrand()) || params.getBrand()==null)){
            boolQuery.filter(QueryBuilders.termQuery("brand", params.getBrand()));
        }
        if (!("".equals(params.getStarName()) || params.getStarName()==null)){
            boolQuery.filter(QueryBuilders.termQuery("starName", params.getStarName()));
        }
        return boolQuery;
    }

    private static PageResult extracted(SearchResponse response) {
        SearchHits searchHits = response.getHits();
        long total = searchHits.getTotalHits().value;
        SearchHit[] hits = searchHits.getHits();
        List<HotelDoc> list = Arrays.stream(hits).map(item -> {
            String jsonStr = item.getSourceAsString();
            Object[] sortValues = item.getSortValues();
            HotelDoc hotelDoc = JSONObject.parseObject(jsonStr, HotelDoc.class);
            return hotelDoc;
        }).collect(Collectors.toList());
        return new PageResult(total, list);
    }
}

分頁排序

ES實戰(zhàn) | 黑馬旅游案例

需求:實現(xiàn)分頁排序

思路:分頁跟排序是單獨的功能,可以根據(jù)選項排好序再分頁

@Service
public class HotelService extends ServiceImpl<HotelMapper, Hotel> implements IHotelService {
    @Autowired
    private RestHighLevelClient client;
    private static Boolean isLocation = false;
    @Override
    public PageResult search(RequestParams params) throws IOException {
        SearchRequest request = new SearchRequest("hotel");
//        關(guān)鍵字搜索
        QueryBuilder query = buildBasicQuery(params);
        request.source().query(query);
//        分頁
        int page = params.getPage();
        int size = params.getSize();
        request.source().from((page-1)*size).size(size);
//        排序
        if (!("default".equals(params.getSortBy()))){
            FieldSortBuilder sortBy = SortBuilders.fieldSort(params.getSortBy());
            if ("price".equals(params.getSortBy())){
                sortBy.order(SortOrder.ASC);
            }else {
                sortBy.order(SortOrder.DESC);
            }
            request.source().sort(sortBy);
        }
        SearchResponse response = client.search(request, RequestOptions.DEFAULT);
        return extracted(response);
    }

    private static QueryBuilder buildBasicQuery(RequestParams params) {
        String key  = params.getKey();
        BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
//        query
//        關(guān)鍵字搜索
        if ("".equals(key) || key==null){
            boolQuery.must(QueryBuilders.matchAllQuery());
        }else {
            boolQuery.must(QueryBuilders.matchQuery("all",key));
        }
//        過濾條件
        if (params.getMinPrice()!=null && params.getMaxPrice()!=null){
            boolQuery.filter(QueryBuilders.rangeQuery("price").gte(params.getMinPrice()).lte(params.getMaxPrice()));
        }
        if (!("".equals(params.getCity()) || params.getCity()==null)){
            boolQuery.filter(QueryBuilders.termQuery("city", params.getCity()));
        }
        if (!("".equals(params.getBrand()) || params.getBrand()==null)){
            boolQuery.filter(QueryBuilders.termQuery("brand", params.getBrand()));
        }
        if (!("".equals(params.getStarName()) || params.getStarName()==null)){
            boolQuery.filter(QueryBuilders.termQuery("starName", params.getStarName()));
        }
		return boolQuery;
    }

    private static PageResult extracted(SearchResponse response) {
        SearchHits searchHits = response.getHits();
        long total = searchHits.getTotalHits().value;
        SearchHit[] hits = searchHits.getHits();
        List<HotelDoc> list = Arrays.stream(hits).map(item -> {
            String jsonStr = item.getSourceAsString();
            Object[] sortValues = item.getSortValues();
            HotelDoc hotelDoc = JSONObject.parseObject(jsonStr, HotelDoc.class);
            return hotelDoc;
        }).collect(Collectors.toList());
        return new PageResult(total, list);
    }
}

距離顯示

ES實戰(zhàn) | 黑馬旅游案例

要求:點擊獲取位置后,根據(jù)距離顯示酒店,且要顯示距離

思路:先判斷有沒有點擊地圖,如果攜帶了位置的請求就代表點擊了地圖,就需要根據(jù)坐標(biāo)查詢,且規(guī)定坐標(biāo)先查找,可以保證在sort里value[0]就是坐標(biāo)值

ES實戰(zhàn) | 黑馬旅游案例

@Service
public class HotelService extends ServiceImpl<HotelMapper, Hotel> implements IHotelService {
    @Autowired
    private RestHighLevelClient client;
    private static Boolean isLocation = false;
    @Override
    public PageResult search(RequestParams params) throws IOException {
        SearchRequest request = new SearchRequest("hotel");
//        關(guān)鍵字搜索
        QueryBuilder query = buildBasicQuery(params);
        request.source().query(query);
//        分頁
        int page = params.getPage();
        int size = params.getSize();
        request.source().from((page-1)*size).size(size);
//        排序
        String location = params.getLocation();
//        坐標(biāo)排序
        if (!("".equals(location) || location==null)){
            GeoDistanceSortBuilder locationSort = SortBuilders.geoDistanceSort("location",new GeoPoint(location)).order(SortOrder.ASC).unit(DistanceUnit.KILOMETERS);
            request.source().sort(locationSort);
            FieldSortBuilder priceSort = SortBuilders.fieldSort("price").order(SortOrder.ASC);
            request.source().sort(priceSort);
            isLocation =true;
        }
//		  price/defult/socre排序        
        if (!("default".equals(params.getSortBy()))){
            FieldSortBuilder sortBy = SortBuilders.fieldSort(params.getSortBy());
            if ("price".equals(params.getSortBy())){
                sortBy.order(SortOrder.ASC);
            }else {
                sortBy.order(SortOrder.DESC);
            }
            request.source().sort(sortBy);
        }
        SearchResponse response = client.search(request, RequestOptions.DEFAULT);
        return extracted(response);
    }

    private static QueryBuilder buildBasicQuery(RequestParams params) {
        String key  = params.getKey();
        BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
//        query
//        關(guān)鍵字搜索
        if ("".equals(key) || key==null){
            boolQuery.must(QueryBuilders.matchAllQuery());
        }else {
            boolQuery.must(QueryBuilders.matchQuery("all",key));
        }
//        過濾條件
        if (params.getMinPrice()!=null && params.getMaxPrice()!=null){
            boolQuery.filter(QueryBuilders.rangeQuery("price").gte(params.getMinPrice()).lte(params.getMaxPrice()));
        }
        if (!("".equals(params.getCity()) || params.getCity()==null)){
            boolQuery.filter(QueryBuilders.termQuery("city", params.getCity()));
        }
        if (!("".equals(params.getBrand()) || params.getBrand()==null)){
            boolQuery.filter(QueryBuilders.termQuery("brand", params.getBrand()));
        }
        if (!("".equals(params.getStarName()) || params.getStarName()==null)){
            boolQuery.filter(QueryBuilders.termQuery("starName", params.getStarName()));
        }
		return boolQuery;
    }

    private static PageResult extracted(SearchResponse response) {
        SearchHits searchHits = response.getHits();
        long total = searchHits.getTotalHits().value;
        SearchHit[] hits = searchHits.getHits();
        List<HotelDoc> list = Arrays.stream(hits).map(item -> {
            String jsonStr = item.getSourceAsString();
            Object[] sortValues = item.getSortValues();
            HotelDoc hotelDoc = JSONObject.parseObject(jsonStr, HotelDoc.class);
            if (sortValues.length>0 && isLocation){
                Object sortValue = sortValues[0];
                hotelDoc.setDistance(sortValue);
            }
            return hotelDoc;
        }).collect(Collectors.toList());
        return new PageResult(total, list);
    }
}

廣告置頂

ES實戰(zhàn) | 黑馬旅游案例

要求:廣告置頂,有些廣告需要在展示搜索結(jié)果的時候排在前面

思路:利用functionScore來做,但是functionScore是用不到bool的只能用普通的查詢,在文檔中維護一個字段叫isAD,在functions中過濾出isAD的文檔,重新分配權(quán)重

@Service
public class HotelService extends ServiceImpl<HotelMapper, Hotel> implements IHotelService {
    @Autowired
    private RestHighLevelClient client;
    private static Boolean isLocation = false;
    @Override
    public PageResult search(RequestParams params) throws IOException {
        SearchRequest request = new SearchRequest("hotel");
//        關(guān)鍵字搜索
        QueryBuilder query = buildBasicQuery(params);
        request.source().query(query);
//        分頁
        int page = params.getPage();
        int size = params.getSize();
        request.source().from((page-1)*size).size(size);
//        排序
        String location = params.getLocation();
        if (!("".equals(location) || location==null)){
            GeoDistanceSortBuilder locationSort = SortBuilders.geoDistanceSort("location",new GeoPoint(location)).order(SortOrder.ASC).unit(DistanceUnit.KILOMETERS);
            request.source().sort(locationSort);
            FieldSortBuilder priceSort = SortBuilders.fieldSort("price").order(SortOrder.ASC);
            request.source().sort(priceSort);
            isLocation =true;
        }
        if (!("default".equals(params.getSortBy()))){
            FieldSortBuilder sortBy = SortBuilders.fieldSort(params.getSortBy());
            if ("price".equals(params.getSortBy())){
                sortBy.order(SortOrder.ASC);
            }else {
                sortBy.order(SortOrder.DESC);
            }
            request.source().sort(sortBy);
        }
        SearchResponse response = client.search(request, RequestOptions.DEFAULT);
        return extracted(response);
    }

    private static QueryBuilder buildBasicQuery(RequestParams params) {
        String key  = params.getKey();
        BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
//        query
//        關(guān)鍵字搜索
        if ("".equals(key) || key==null){
            boolQuery.must(QueryBuilders.matchAllQuery());
        }else {
            boolQuery.must(QueryBuilders.matchQuery("all",key));
        }
//        過濾條件
        if (params.getMinPrice()!=null && params.getMaxPrice()!=null){
            boolQuery.filter(QueryBuilders.rangeQuery("price").gte(params.getMinPrice()).lte(params.getMaxPrice()));
        }
        if (!("".equals(params.getCity()) || params.getCity()==null)){
            boolQuery.filter(QueryBuilders.termQuery("city", params.getCity()));
        }
        if (!("".equals(params.getBrand()) || params.getBrand()==null)){
            boolQuery.filter(QueryBuilders.termQuery("brand", params.getBrand()));
        }
        if (!("".equals(params.getStarName()) || params.getStarName()==null)){
            boolQuery.filter(QueryBuilders.termQuery("starName", params.getStarName()));
        }

//        廣告置頂
        return QueryBuilders.functionScoreQuery(boolQuery, new FunctionScoreQueryBuilder.FilterFunctionBuilder[]{
                new FunctionScoreQueryBuilder.FilterFunctionBuilder(
                        QueryBuilders.termQuery("isAD",true),
                        ScoreFunctionBuilders.weightFactorFunction(10)
                )
        }).boostMode(CombineFunction.MULTIPLY);
    }

    private static PageResult extracted(SearchResponse response) {
        SearchHits searchHits = response.getHits();
        long total = searchHits.getTotalHits().value;
        SearchHit[] hits = searchHits.getHits();
        List<HotelDoc> list = Arrays.stream(hits).map(item -> {
            String jsonStr = item.getSourceAsString();
            Object[] sortValues = item.getSortValues();
            HotelDoc hotelDoc = JSONObject.parseObject(jsonStr, HotelDoc.class);
            if (sortValues.length>0 && isLocation){
                Object sortValue = sortValues[0];
                hotelDoc.setDistance(sortValue);
            }
            return hotelDoc;
        }).collect(Collectors.toList());
        return new PageResult(total, list);
    }
}

標(biāo)簽聚合

ES實戰(zhàn) | 黑馬旅游案例

需求:從后臺文檔中獲取實際數(shù)據(jù),傳入前端頁面顯示,且會動態(tài)變化,比如:選擇了上海,就展示在上海的品牌,而不在上海的品牌就不顯示

思路:先根據(jù)用戶條件搜索文檔,按照類別聚合

    @Override
    public Map<String, List<String>> filters(RequestParams requestParams){
        Map<String, List<String>> listMap = null;
        try {
            SearchRequest request = new SearchRequest("hotel");
//        查詢條件構(gòu)建
            searchAggs(request,requestParams);
            SearchResponse response = client.search(request, RequestOptions.DEFAULT);
            Aggregations aggregations = response.getAggregations();
            listMap = new HashMap<>();
            listMap.put("city",getList(aggregations, "getCity"));
            listMap.put("brand",getList(aggregations, "getBrand"));
            listMap.put("starName",getList(aggregations, "getStarName"));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return listMap;
    }

    private void searchAggs(SearchRequest request,RequestParams requestParams) {
        QueryBuilder queryBuilder = buildBasicQuery(requestParams);
        request.source().query(queryBuilder);
//        查詢品牌
        request.source().aggregation(
                AggregationBuilders
                        .terms("getBrand")
                        .field("brand")
                        .size(20));
//        查詢城市
        request.source().aggregation(
                AggregationBuilders
                        .terms("getCity")
                        .field("city")
                        .size(20));
//        查詢星級
        request.source().aggregation(
                AggregationBuilders
                        .terms("getStarName")
                        .field("starName")
                        .size(20));
    }

    private List<String> getList(Aggregations aggregations, String name) {
        Terms getBrand = aggregations.get(name);
        List<String> list = new ArrayList<>();
        for (Terms.Bucket bucket : getBrand.getBuckets()) {
            String key = bucket.getKeyAsString();
            list.add(key);
        }
        return list;
    }

    private QueryBuilder buildBasicQuery(RequestParams params) {
        String key  = params.getKey();
        BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
//        query
//        關(guān)鍵字搜索
        if ("".equals(key) || key==null){
            boolQuery.must(QueryBuilders.matchAllQuery());
        }else {
            boolQuery.must(QueryBuilders.matchQuery("all",key));
        }
//        過濾條件
        if (params.getMinPrice()!=null && params.getMaxPrice()!=null){
            boolQuery.filter(QueryBuilders.rangeQuery("price").gte(params.getMinPrice()).lte(params.getMaxPrice()));
        }
        if (!("".equals(params.getCity()) || params.getCity()==null)){
            boolQuery.filter(QueryBuilders.termQuery("city", params.getCity()));
        }
        if (!("".equals(params.getBrand()) || params.getBrand()==null)){
            boolQuery.filter(QueryBuilders.termQuery("brand", params.getBrand()));
        }
        if (!("".equals(params.getStarName()) || params.getStarName()==null)){
            boolQuery.filter(QueryBuilders.termQuery("starName", params.getStarName()));
        }

//        廣告置頂
        return QueryBuilders.functionScoreQuery(boolQuery, new FunctionScoreQueryBuilder.FilterFunctionBuilder[]{
                new FunctionScoreQueryBuilder.FilterFunctionBuilder(
                        QueryBuilders.termQuery("isAD",true),
                        ScoreFunctionBuilders.weightFactorFunction(10)
                )
        }).boostMode(CombineFunction.MULTIPLY);
    }

自動補全

ES實戰(zhàn) | 黑馬旅游案例

需求:要求用戶輸入拼音,可以根據(jù)輸入的拼音自動補全,例如:輸入s自動補全 三,四,蛇

思路:利用分詞器,在新增文檔的時候,根據(jù)拼音分詞器把品牌,地址做拆分,用戶輸入受字母的時候,后臺根據(jù)首字符檢索字段的拼音,要設(shè)計好拼音分詞器的拆分條件

/**
 * 自動補全
 * @param key 補全前綴
 * @return 補全數(shù)組
 */
@Override
public List<String> suggestion(String key) {
    List<String> collect;
    try {
        SearchRequest request = new SearchRequest("hotel");
        request.source().suggest(new SuggestBuilder()
                .addSuggestion("mySuggestion",
                        SuggestBuilders
                                .completionSuggestion("suggestion")
                                .prefix(key)
                                .skipDuplicates(true)
                                .size(10)));
        SearchResponse response = client.search(request, RequestOptions.DEFAULT);
        CompletionSuggestion mySuggestion = response.getSuggest().getSuggestion("mySuggestion");
        List<CompletionSuggestion.Entry.Option> options = mySuggestion.getOptions();
        collect = options.stream().map(item -> item.getText().string()).collect(Collectors.toList());
        System.err.println(collect);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return collect;
}

構(gòu)建索引庫比較關(guān)鍵,這里把用不到的字段省略了,不然太冗余了

#hotel
PUT /hotel
{
  "mappings":{
    "properties":{
      "address":{
        "type": "keyword",
        "copy_to": "all"
      },
      "brand":{
        "type": "keyword",
        "copy_to": "all"
      },    
      "city":{
        "type": "keyword",
        "copy_to": "all"
      },
      "name":{
        "type": "text",
        "analyzer": "text_analyzere",
        "search_analyzer": "ik_smart",
        "copy_to": "all"
      },
      # all字段,用戶確認搜索的時候用到的。analyzer代表新增文檔的時候,按照text_analyzere這個分詞器,根據(jù)最大粒度拆分,且用到了py拼音分詞器。
      # search_analyzer,用戶確認搜索的時候用這個分詞器去拆分用戶的輸入信息
      "all":{
        "type": "text",
        "analyzer": "text_analyzere",
        "search_analyzer": "ik_max_word"
      },
      #suggestion專門為自動補全做的字段,類型只能是completion,completion是一個數(shù)組,數(shù)組內(nèi)的字段只能是keyword不能拆分,因為如果拆分的話就有很多個值出來,keyword保證不可拆分,那么在同一個文檔內(nèi)這個suggestion是固定的,比如completion由品牌跟地址組成,品牌=如家,地址=北京,那這個分詞器拆出來只能是:rujia/rj,beijing/bj,
      "suggestion":{
        "type": "completion",
        "analyzer": "completion_analyzere"
      }
    }
  },
  "settings": {
    "analysis": {
      "analyzer": {
      #text的分詞器,新增文檔的時候有些text字段可能搜索的時候需要用到。
        "text_analyzere":{
          "tokenizer":"ik_max_word",
          "filter":"py"
        },
      #completion的分詞器
        "completion_analyzere":{
          "tokenizer":"keyword",
          "filter":"py"
        }
      },
      "filter": {
          "type": "pinyin", //類型
          "keep_full_pinyin": false,//當(dāng)啟用這個選項,如: 劉德華 >[ liu , de , hua ),默認值:真的
          "keep_joined_full_pinyin": true,//當(dāng)啟用此選項時,例如: 劉德華 >[ liudehua ],默認:false
          "keep_original": true,//當(dāng)啟用此選項時,將保留原始輸入,默認值:false
          "limit_first_letter_length": 16,//set first_letter結(jié)果的最大長度,默認值:16
          "remove_duplicated_term": true,//當(dāng)此選項啟用時,重復(fù)項將被刪除以保存索引,例如: de的 > de ,默認:false,注:職位相關(guān)查詢可能會受到影響
          "none_chinese_pinyin_tokenize" :false //非中國字母分解成單獨的拼音詞如果拼音,默認值:true,如:liu , de , hua , a , li , ba , ba , 13 , zhuang , han ,注意: keep_none_chinese 和 keep_none_chinese_together 應(yīng)該啟用
      }
    }
  }
}

數(shù)據(jù)同步

利用mq實現(xiàn)數(shù)據(jù)同步

生產(chǎn)者

@PostMapping
public void saveHotel(@RequestBody Hotel hotel){
    Long i = 1L;
    hotel.setId(i);
    hotelService.save(hotel);
    String exchangeName = "topic.hotel";
    String key = "hotel.insert";
    rabbitTemplate.convertAndSend(exchangeName,key,hotel.getId());
    System.err.println("發(fā)送成功--->新增");
}

消費者文章來源地址http://www.zghlxwxcb.cn/news/detail-408471.html

@Bean
public Queue queueInsert(){
    return new Queue("topic.insert.queue",true);
}
@Bean
public TopicExchange topicExchange(){
    return new TopicExchange("topic.hotel");
}
@Bean
public Queue queueDelete(){
    return new Queue("topic.delete.queue",true);
}
@Bean
public Binding bindingTopicBuilder(TopicExchange topicExchange,Queue queueInsert){
    return BindingBuilder.bind(queueInsert).to(topicExchange).with("hotel.insert");
}
@Bean
public Binding bindingTopicBuilder2(TopicExchange topicExchange,Queue queueDelete){
    return BindingBuilder.bind(queueDelete).to(topicExchange).with("hotel.delete");
}
@Component
public class ListenMq {
    @Autowired
    private IHotelService hotelService;
    @RabbitListener(queues = "topic.insert.queue")
    public void listenInsert(Long id){
        hotelService.updateById(id);
    }

    @RabbitListener(queues = "topic.delete.queue")
    public void listenDelete(Long id){
        hotelService.deleteById(id);
    }
}
@Override
public void updateById(Long id) {
    try {
        IndexRequest request = new IndexRequest("hotel").id(id.toString());
        Hotel hotel = this.getById(id);
        HotelDoc hotelDoc = new HotelDoc(hotel);
        String jsonString = JSON.toJSONString(hotelDoc);
        request.source(jsonString, XContentType.JSON);
        client.index(request, RequestOptions.DEFAULT);
        System.err.println("新增一條數(shù)據(jù)");
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

到了這里,關(guān)于ES實戰(zhàn) | 黑馬旅游案例的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • Elasticsearch的關(guān)鍵詞搜索

    返回給前端的實體類 es對應(yīng)的實體類 前端傳遞的搜索參數(shù)實體類 controller層 service層接口 service實現(xiàn)類 Springboot啟動類

    2023年04月08日
    瀏覽(30)
  • VIM統(tǒng)計搜索關(guān)鍵詞命令

    :%s/.//gn ? ? ? ?統(tǒng)計字符數(shù) :%s/i+//gn ? ?統(tǒng)計單詞數(shù) :%s/^//n ? ? ? ? ? 統(tǒng)計行數(shù) :%s/keyword//g ? ? ?統(tǒng)計任何地方出現(xiàn)的 \\\"keyword\\\"?? :%s/keyword//gn ? ?統(tǒng)計任何地方出現(xiàn)的 \\\"keyword\\\" :%s/keyword/ :這部分是 Vim 的替換命令的開頭。:%s 表示在整個文件范圍內(nèi)進行替換操作。keyword 是要查

    2024年02月09日
    瀏覽(25)
  • X書關(guān)鍵詞協(xié)議搜索

    搜索接口中的其他java層加密,詳細見: https://codeooo.blog.csdn.net/article/details/122986633

    2024年02月16日
    瀏覽(23)
  • 網(wǎng)站優(yōu)化搜索引擎與關(guān)鍵詞

    網(wǎng)站優(yōu)化搜索引擎與 人們不應(yīng)該高估搜索引擎的智商。這不利于seo的研究,事實上,搜索引擎是非常愚蠢的,讓我們舉一個非常簡單的例子,你在搜索引擎中輸入“教師”這個詞,搜索引擎就會給出一個準確的搜索列表。我們不會給出“教師”一詞的檢索信息,但我們

    2024年02月09日
    瀏覽(118)
  • Vue實現(xiàn)搜索關(guān)鍵詞高亮顯示

    Vue實現(xiàn)搜索關(guān)鍵詞高亮顯示

    最近寫移動端項目的時候,遇到搜索高亮的需求,寫篇文章紀錄一下 先看效果: ? 以上為實現(xiàn)效果展示; 整體思路 : 對后臺返回的數(shù)據(jù)進行操作,(我這里是模擬數(shù)據(jù)),使用正則去匹配搜索后,使用replace進行字符串的替換; 渲染數(shù)據(jù)部分使用v-html進行動態(tài)展示即可

    2024年02月15日
    瀏覽(22)
  • 抖音關(guān)鍵詞搜索小程序排名怎么做

    抖音關(guān)鍵詞搜索小程序排名怎么做

    抖音搜索小程序排名怎么做 1 分鐘教你制作一個抖音小程序。 抖音小程序就是我的視頻,左下方這個藍色的鏈接,點進去就是抖音小程序。 如果你有了這個小程序,發(fā)布視頻的時候可以掛載這個小程序,直播的時候也可以掛載這個小程序進行帶貨。 ? 制作小程序一共

    2024年02月13日
    瀏覽(37)
  • highlight.js 實現(xiàn)搜索關(guān)鍵詞高亮效果

    highlight.js 實現(xiàn)搜索關(guān)鍵詞高亮效果

    先看效果: 更新:增加切換顯示 折騰了老半天,記錄一下 注意事項都寫注釋了 代碼: 更新后代碼:

    2024年02月02日
    瀏覽(18)
  • Python獲取高德POI(關(guān)鍵詞搜索法)

    Python獲取高德POI(關(guān)鍵詞搜索法)

    該篇文章是搜索法獲取高德poi,但鑒于無法突破900條記錄的上限,因此重寫了 矩形搜索法 的文章,具體可參考以下文章: 高德poi獲取之矩形搜索法(沖出900條限制) (建議沒有python基礎(chǔ)的朋友先閱讀該篇再看矩形搜索法!) 首先我們需要明白一些常識 poi是興趣點,它

    2024年02月06日
    瀏覽(21)
  • springboot——集成elasticsearch進行搜索并高亮關(guān)鍵詞

    springboot——集成elasticsearch進行搜索并高亮關(guān)鍵詞

    目錄 1.elasticsearch概述 3.springboot集成elasticsearch 4.實現(xiàn)搜索并高亮 (1)是什么: Elasticsearch 是位于 Elastic Stack 核心的分布式搜索和分析引擎。 Lucene 可以被認為是迄今為止最先進、性能最好的、功能最全的搜索引擎庫。但Lucene 只是一個基于java下的庫,需要使用 Java 并要

    2023年04月20日
    瀏覽(27)
  • 【爬蟲】根據(jù)關(guān)鍵詞自動搜索并爬取結(jié)果

    根據(jù)自動搜索并爬取網(wǎng)頁的信息 網(wǎng)頁有兩種情況:可以直接獲取頁數(shù)的和不可以直接獲取頁數(shù)的; 兩種情況可以采取不同的方法: 情況一:先爬取頁數(shù),再爬取每頁的數(shù)據(jù) 情況二:無法爬取到頁碼數(shù),只能換頁爬取的

    2024年02月12日
    瀏覽(26)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包