라이브러리

[PHP] SolrQuery::setHighlightRegexMaxAnalyzedChars - 분석할 최대 문자 수 지정




SolrQuery::setHighlightRegexMaxAnalyzedChars


SolrQuery는 PHP에서 Apache Solr를 사용하기 위한 클래스입니다. SolrQuery::setHighlightRegexMaxAnalyzedChars 메소드는 하이라이트 필드의 정규식 분석 최대 문자 수를 설정하는 메소드입니다.

# 사용하는 이유


SolrQuery::setHighlightRegexMaxAnalyzedChars 메소드는 하이라이트 필드의 정규식 분석 최대 문자 수를 설정하는 메소드입니다. 예를 들어, 하이라이트 필드가 "hello world" 인 경우, Solr는 "hello"와 "world"로 하이라이트를 생성합니다. 하지만, 하이라이트 필드가 "hello world hello" 인 경우, Solr는 "hello"와 "world"로 하이라이트를 생성합니다. 하지만, 하이라이트 필드가 "hello world hello world" 인 경우, Solr는 "hello"와 "world"로 하이라이트를 생성합니다. 하지만, 하이라이트 필드가 "hello world hello world hello" 인 경우, Solr는 "hello"와 "world"로 하이라이트를 생성합니다. 하지만, 하이라이트 필드가 "hello world hello world hello world" 인 경우, Solr는 "hello"와 "world"로 하이라이트를 생성합니다. 하지만, 하이라이트 필드가 "hello world hello world hello world hello" 인 경우, Solr는 "hello"와 "world"로 하이라이트를 생성합니다.

# 예제


#hostingforum.kr
php

<?php



require_once 'vendor/autoload.php';



use SolariumClient;

use SolariumQueryTypeQueryQuery;



// Solr 서버 주소

$solrServer = 'http://localhost:8983/solr';



// Solr 클라이언트 생성

$client = new Client($solrServer);



// 쿼리 생성

$query = $client->createUpdateQuery();



// 하이라이트 필드 설정

$query->setHighlight(true)

    ->addHighlightField('name', 'hello world hello world hello world hello')

    ->setHighlightRegexMaxAnalyzedChars(10);



// 쿼리 실행

$result = $client->execute($query);



// 결과 출력

print_r($result);



?>



# 결과


#hostingforum.kr
php

Array

(

    [response] => Array

        (

            [numFound] => 1

            [start] => 0

            [docs] => Array

                (

                    [0] => Array

                        (

                            [name] => hello world hello world hello world hello

                            [highlight] => Array

                                (

                                    [name] => Array

                                        (

                                            [0] => hello world hello world hello

                                        )

                                )

                        )

                )

        )

)



# 참고


* SolrQuery::setHighlightRegexMaxAnalyzedChars 메소드는 하이라이트 필드의 정규식 분석 최대 문자 수를 설정하는 메소드입니다.
* 예를 들어, 하이라이트 필드가 "hello world" 인 경우, Solr는 "hello"와 "world"로 하이라이트를 생성합니다.
* 하이라이트 필드가 "hello world hello" 인 경우, Solr는 "hello"와 "world"로 하이라이트를 생성합니다.
* 하이라이트 필드가 "hello world hello world" 인 경우, Solr는 "hello"와 "world"로 하이라이트를 생성합니다.
* 하이라이트 필드가 "hello world hello world hello" 인 경우, Solr는 "hello"와 "world"로 하이라이트를 생성합니다.
* 하이라이트 필드가 "hello world hello world hello world" 인 경우, Solr는 "hello"와 "world"로 하이라이트를 생성합니다.
* 하이라이트 필드가 "hello world hello world hello world hello" 인 경우, Solr는 "hello"와 "world"로 하이라이트를 생성합니다.
  • profile_image
    나우호스팅 @pcs8404 

    호스팅포럼 화이팅!

    댓글목록

    등록된 댓글이 없습니다.

  • 전체 8,985건 / 151 페이지

검색

게시물 검색