当前位置: 首页>>代码示例>>Java>>正文


Java SearchParameters.setSearchTerm方法代码示例

本文整理汇总了Java中org.alfresco.service.cmr.search.SearchParameters.setSearchTerm方法的典型用法代码示例。如果您正苦于以下问题:Java SearchParameters.setSearchTerm方法的具体用法?Java SearchParameters.setSearchTerm怎么用?Java SearchParameters.setSearchTerm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alfresco.service.cmr.search.SearchParameters的用法示例。


在下文中一共展示了SearchParameters.setSearchTerm方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testBuildStats

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Test
public void testBuildStats() throws UnsupportedEncodingException
{
    SearchParameters params = new SearchParameters();
    params.setSearchTerm("bob");
    params.setStats(Arrays.asList(
                new StatsRequestParameters("created", null, null, null, null,null, null, null, null,
                            null, null, null, null,null, null,  null),
                new StatsRequestParameters("cm:name", "statLabel",
                Arrays.asList(2.4f, 99.9f),null, null, false, null,false, null, false, null, true, true,
                true, 0.5f, Arrays.asList("excludeme"))));

    StringBuilder urlBuilder = new StringBuilder();
    client.buildStatsParameters(params, encoder, urlBuilder);
    String url = urlBuilder.toString();
    assertNotNull(url);
    assertTrue(url.contains("&stats=true"));
    assertTrue(url.contains("stats.field=" + encoder.encode(
               "{! countDistinct=false distinctValues=false min=true max=true sum=true count=true missing=true sumOfSquares=true mean=true stddev=true}created", "UTF-8")));
    assertTrue(url.contains("stats.field=" + encoder.encode(
               "{! ex=excludeme tag=statLabel key=statLabel percentiles='2.4,99.9' cardinality=0.5 countDistinct=true distinctValues=true min=true max=true sum=false count=true missing=false sumOfSquares=true mean=false stddev=true}cm:name", "UTF-8")));

}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:SolrQueryHTTPClientTest.java

示例2: testBuildRangeDate

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Test
public void testBuildRangeDate() throws UnsupportedEncodingException
{
    TimeZone defaultTimeZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

    SearchParameters params = new SearchParameters();
    params.setSearchTerm("A*");
    List<RangeParameters> ranges = new ArrayList<RangeParameters>();
    ranges.add(new RangeParameters("created", "2015", "2016", "+1MONTH", true, Collections.emptyList(), Collections.emptyList(), null, null));
    params.setRanges(ranges);
    StringBuilder urlBuilder = new StringBuilder();
    client.buildRangeParameters(params, encoder, urlBuilder);
    String url = urlBuilder.toString();
    assertNotNull(url);
    assertTrue(url.contains("&facet=true"));
    assertTrue(url.contains("&facet.range=created"));
    assertTrue(url.contains("&f.created.facet.range.start=2015-01-01T00%3A00%3A00.000Z"));
    assertTrue(url.contains("&f.created.facet.range.end=2016-12-31T23%3A59%3A59.999Z"));
    assertTrue(url.contains("&f.created.facet.range.gap=%2B1MONTH"));

    TimeZone.setDefault(defaultTimeZone);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:SolrQueryHTTPClientTest.java

示例3: fromQuery

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
/**
 * SearchParameters from the Query object
 * @param sp SearchParameters
 * @param q Query
 */
public void fromQuery(SearchParameters sp, Query q)
{
    ParameterCheck.mandatoryString("query", q.getQuery());
    String lang = q.getLanguage()==null?AFTS:q.getLanguage();

    switch (lang.toLowerCase())
    {
        case AFTS:
            sp.setLanguage(LANGUAGE_FTS_ALFRESCO);
            break;
        case LUCENE:
            sp.setLanguage(LANGUAGE_LUCENE);
            break;
        case CMIS:
            sp.setLanguage(LANGUAGE_CMIS_ALFRESCO);
            break;
        default:
            throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_MESSAGE_ID,
                        new Object[] { ": language allowed values: afts,lucene,cmis" });
    }
    sp.setQuery(q.getQuery());
    sp.setSearchTerm(q.getUserQuery());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:29,代码来源:SearchMapper.java

示例4: fromSpellCheck

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
/**
 * SearchParameters from SpellCheck object
 * @param sp SearchParameters
 * @param defaults SpellCheck
 */
public void fromSpellCheck(SearchParameters sp, Spelling spelling)
{
    if (spelling != null)
    {
        if (spelling.getQuery() != null && !spelling.getQuery().isEmpty())
        {
            sp.setSearchTerm(spelling.getQuery());
        }
        else
        {
            if (sp.getSearchTerm() == null || sp.getSearchTerm().isEmpty())
            {
                //We don't have a valid search term to use with the spelling
                throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_MESSAGE_ID,
                            new Object[] { ": userQuery or spelling.query required." });
            }
        }
        sp.setSpellCheck(true);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:26,代码来源:SearchMapper.java

示例5: testBuildPivots

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Test
public void testBuildPivots() throws UnsupportedEncodingException
{
    SearchParameters params = new SearchParameters();
    params.setSearchTerm("bob");
    params.addPivots(Arrays.asList("creator"));
    params.setStats(Arrays.asList(
                new StatsRequestParameters("created", "piv1", null, null, null,null, null, null, null,
                            null, null, null, null,null, null,  null)
                ));
    List<RangeParameters> ranges = new ArrayList<RangeParameters>();
    ranges.add(new RangeParameters("content.size","0","1000000", "10000", true, Collections.emptyList(), Collections.emptyList(), "csize",null));
    params.setRanges(ranges);

    StringBuilder urlBuilder = new StringBuilder();

    client.buildPivotParameters(params, encoder, urlBuilder);
    String url = urlBuilder.toString();
    assertNotNull(url);
    assertTrue(url.contains("&facet=true"));
    assertTrue(url.contains("facet.pivot=creator"));

    params.addPivots(Arrays.asList("cm:name", "piv1", "csize"));

    urlBuilder = new StringBuilder();
    client.buildPivotParameters(params, encoder, urlBuilder);
    url = urlBuilder.toString();
    assertNotNull(url);
    assertTrue(url.contains("&facet=true"));
    assertTrue(url.contains("facet.pivot="+ encoder.encode("creator", "UTF-8")));
    assertTrue(url.contains("facet.pivot="+ encoder.encode("{! stats=piv1 range=csize}cm:name", "UTF-8")));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:33,代码来源:SolrQueryHTTPClientTest.java

示例6: testBuildMulitRange

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Test
public void testBuildMulitRange() throws UnsupportedEncodingException
{
    SearchParameters params = new SearchParameters();
    params.setSearchTerm("A*");
    List<RangeParameters> ranges = new ArrayList<RangeParameters>();
    List<String>includes = new ArrayList<String>();
    includes.add("upper");
    includes.add("outer");
    List<String>includes2 = new ArrayList<String>();
    includes2.add("lower");
    List<String> other = new ArrayList<String>();
    other.add("before");
    ranges.add(new RangeParameters("content.size", "0", "1000000", "10000", true, other, includes, null, null));
    ranges.add(new RangeParameters("created", "2015-09-29T10:45:15.729Z", "2016-09-29T10:45:15.729Z", "+100DAY", true, other, includes2, null, null));
    params.setRanges(ranges);
    StringBuilder urlBuilder = new StringBuilder();
    client.buildRangeParameters(params, encoder, urlBuilder);
    String url = urlBuilder.toString();
    assertNotNull(url);
    assertTrue(url.contains("&facet=true"));
    assertTrue(url.contains("&facet.range=content.size"));
    assertTrue(url.contains("&f.content.size.facet.range.start=0"));
    assertTrue(url.contains("&f.content.size.facet.range.end=1000000"));
    assertTrue(url.contains("&f.content.size.facet.range.gap=10000"));
    assertTrue(url.contains("&f.content.size.facet.range.include=upper"));
    assertTrue(url.contains("&f.content.size.facet.range.include=outer"));
    assertTrue(url.contains("&f.content.size.facet.range.hardend=true"));
    assertTrue(url.contains("&facet.range=created"));
    assertTrue(url.contains("&f.created.facet.range.start=2015-09-29T10%3A45%3A15.729Z"));
    assertTrue(url.contains("&f.created.facet.range.end=2016-09-29T10%3A45%3A15.729Z"));
    assertTrue(url.contains("&f.created.facet.range.gap=%2B100DAY"));
    assertTrue(url.contains("&f.created.facet.range.other=before"));
    assertTrue(url.contains("&f.created.facet.range.include=lower"));
    assertTrue(url.contains("&f.created.facet.range.hardend=true"));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:37,代码来源:SolrQueryHTTPClientTest.java

示例7: fromSpelling

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Test
public void fromSpelling() throws Exception
{
    SearchParameters searchParameters = new SearchParameters();
    //Doesn't error
    searchMapper.fromSpellCheck(searchParameters, null);
    assertFalse(searchParameters.isSpellCheck());

    try
    {
        searchMapper.fromSpellCheck(searchParameters, new Spelling(null));
        fail();
    }
    catch (InvalidArgumentException iae)
    {
        //Can't be null
        assertNotNull(iae);
    }

    //Now set search term first
    searchParameters.setSearchTerm("fred");
    searchMapper.fromSpellCheck(searchParameters, new Spelling(null));
    assertEquals("fred",searchParameters.getSearchTerm());

    //Now query replaces userQuery (search term)
    searchMapper.fromSpellCheck(searchParameters, new Spelling("favourit"));
    assertEquals("favourit",searchParameters.getSearchTerm());
    assertTrue(searchParameters.isSpellCheck());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:30,代码来源:SearchMapperTests.java

示例8: testBuildHighlightQuery

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Test
public void testBuildHighlightQuery() throws UnsupportedEncodingException
{
    SearchParameters params = new SearchParameters();
    params.setSearchTerm("bob");
    StringBuilder urlBuilder = new StringBuilder();
    client.buildUrlParameters(params, false, encoder, urlBuilder);
    String url = urlBuilder.toString();
    assertNotNull(url);
    assertFalse(url.contains("&hl"));

    urlBuilder = new StringBuilder();
    GeneralHighlightParameters highlightParameters = new GeneralHighlightParameters(null, null, null, null, null, null, null, null);
    params.setHighlight(highlightParameters);
    client.buildUrlParameters(params, true, encoder, urlBuilder);
    url = urlBuilder.toString();
    assertTrue(url.contains("&hl=true"));
    assertTrue(url.contains("&hl.q=bob"));

    urlBuilder = new StringBuilder();
    highlightParameters = new GeneralHighlightParameters(5, 10, false, "{", "}", 20, true, null);
    params.setHighlight(highlightParameters);
    client.buildUrlParameters(params, false, encoder, urlBuilder);
    url = urlBuilder.toString();
    assertTrue(url.contains("&hl=true"));
    assertTrue(url.contains("&hl.q=bob"));
    assertTrue(url.contains("&hl.snippets=5"));
    assertTrue(url.contains("&hl.fragsize=10"));
    assertTrue(url.contains("&hl.maxAnalyzedChars=20"));
    assertTrue(url.contains("&hl.mergeContiguous=false"));
    assertTrue(url.contains("&hl.usePhraseHighlighter=true"));

    assertTrue(url.contains("&hl.simple.pre=" + encoder.encode("{", "UTF-8")));
    assertTrue(url.contains("&hl.simple.post=" + encoder.encode("}", "UTF-8")));

    List<FieldHighlightParameters> fields = Arrays.asList(new FieldHighlightParameters(null, null, null, null, null, null));
    urlBuilder = new StringBuilder();
    highlightParameters = new GeneralHighlightParameters(5, 10, false, "{", "}", 20, true, fields);
    params.setHighlight(highlightParameters);

    try
    {
        client.buildUrlParameters(params, false, encoder, urlBuilder);
        fail();
    }
    catch (IllegalArgumentException iae)
    {
        assertNotNull("no fieldname specfied so invalid", iae);
    }

    fields = Arrays.asList(new FieldHighlightParameters("desc", 50, 100, false, "@", "#"),
                new FieldHighlightParameters("title", 55, 105, true, "*", "¿"));
    urlBuilder = new StringBuilder();
    highlightParameters = new GeneralHighlightParameters(5, 10, false, "{", "}", 20, true, fields);
    params.setHighlight(highlightParameters);
    client.buildUrlParameters(params, false, encoder, urlBuilder);
    url = urlBuilder.toString();
    assertTrue(url.contains("&hl=true"));
    assertTrue(url.contains("&hl.fl=" + encoder.encode("desc,title", "UTF-8")));
    assertTrue(url.contains("&f.desc.hl.snippets=50"));
    assertTrue(url.contains("&f.title.hl.snippets=55"));
    assertTrue(url.contains("&f.desc.hl.fragsize=100"));
    assertTrue(url.contains("&f.title.hl.fragsize=105"));
    assertTrue(url.contains("&f.desc.hl.mergeContiguous=false"));
    assertTrue(url.contains("&f.title.hl.mergeContiguous=true"));
    assertTrue(url.contains("&f.desc.hl.simple.pre=" + encoder.encode("@", "UTF-8")));
    assertTrue(url.contains("&f.desc.hl.simple.post=" + encoder.encode("#", "UTF-8")));
    assertTrue(url.contains("&f.title.hl.simple.pre=" + encoder.encode("*", "UTF-8")));
    assertTrue(url.contains("&f.title.hl.simple.post=" + encoder.encode("¿", "UTF-8")));

}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:72,代码来源:SolrQueryHTTPClientTest.java

示例9: testBuildFieldFacets

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Test
public void testBuildFieldFacets() throws UnsupportedEncodingException
{
    SearchParameters params = new SearchParameters();
    params.setSearchTerm("bob");

    SearchParameters.FieldFacet prefixff = new SearchParameters.FieldFacet("{!afts something=right}modifier");
    SearchParameters.FieldFacet ff = new SearchParameters.FieldFacet("creator");
    params.addFieldFacet(prefixff);
    params.addFieldFacet(ff);

    StringBuilder urlBuilder = new StringBuilder();
    client.buildFacetParameters(params, false, encoder, urlBuilder);
    String url = urlBuilder.toString();
    assertNotNull(url);
    assertTrue(url.contains("&facet=true"));
    assertTrue(url.contains("facet.field=creator"));
    assertTrue(url.contains("f.creator.facet.limit=100"));
    assertTrue(url.contains("facet.field=" + encoder.encode("{!afts something=right}modifier", "UTF-8")));
    assertTrue(url.contains("f.modifier.facet.limit=100"));

    prefixff.setLabel("myLabel");
    ff.setLabel("yourLabel");

    urlBuilder = new StringBuilder();
    client.buildFacetParameters(params, false, encoder, urlBuilder);
    url = urlBuilder.toString();
    assertNotNull(url);
    assertTrue(url.contains("&facet=true"));
    assertTrue(url.contains("facet.field=" + encoder.encode("{!afts key=yourLabel}creator", "UTF-8")));
    assertTrue(url.contains("f.creator.facet.limit=100"));
    assertTrue(url.contains("facet.field=" + encoder.encode("{!afts key=myLabel something=right}modifier", "UTF-8")));
    assertTrue(url.contains("f.modifier.facet.limit=100"));

    prefixff.setExcludeFilters(Arrays.asList("x", "y"));
    ff.setExcludeFilters(Arrays.asList("B"));

    urlBuilder = new StringBuilder();
    client.buildFacetParameters(params, false, encoder, urlBuilder);
    url = urlBuilder.toString();
    assertNotNull(url);
    assertTrue(url.contains("&facet=true"));
    assertTrue(url.contains("facet.field=" + encoder.encode("{!afts ex=B key=yourLabel}creator", "UTF-8")));
    assertTrue(url.contains("f.creator.facet.limit=100"));
    assertTrue(url.contains("facet.field=" + encoder.encode("{!afts ex=x,y key=myLabel something=right}modifier", "UTF-8")));
    assertTrue(url.contains("f.modifier.facet.limit=100"));

    prefixff.setField("bill");
    prefixff.setExcludeFilters(Collections.emptyList());
    ff.setField("{!afts}ben");
    ff.setLabel(null);

    urlBuilder = new StringBuilder();
    client.buildFacetParameters(params, false, encoder, urlBuilder);
    url = urlBuilder.toString();
    assertNotNull(url);
    assertTrue(url.contains("&facet=true"));
    assertTrue(url.contains("facet.field=" + encoder.encode("{!afts ex=B}ben", "UTF-8")));
    assertTrue(url.contains("f.ben.facet.limit=100"));
    assertTrue(url.contains("facet.field=" + encoder.encode("{!afts key=myLabel}bill", "UTF-8")));
    assertTrue(url.contains("f.bill.facet.limit=100"));

}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:64,代码来源:SolrQueryHTTPClientTest.java

示例10: testBuildRange

import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Test
public void testBuildRange() throws UnsupportedEncodingException
{
    SearchParameters params = new SearchParameters();
    params.setSearchTerm("A*");
    List<RangeParameters> ranges = new ArrayList<RangeParameters>();
    List<String>includes = new ArrayList<String>();
    includes.add("upper");
    includes.add("outer");
    List<String> other = new ArrayList<String>();
    other.add("before");
    other.add("between");
    ranges.add(new RangeParameters("content.size", "0", "1000000", "10000", true, other, includes, null, null));
    params.setRanges(ranges);
    StringBuilder urlBuilder = new StringBuilder();
    client.buildRangeParameters(params, encoder, urlBuilder);
    String url = urlBuilder.toString();
    assertNotNull(url);
    assertTrue(url.contains("&facet=true"));
    assertTrue(url.contains("&facet.range=content.size"));
    assertTrue(url.contains("&f.content.size.facet.range.start=0"));
    assertTrue(url.contains("&f.content.size.facet.range.end=1000000"));
    assertTrue(url.contains("&f.content.size.facet.range.gap=10000"));
    assertTrue(url.contains("&f.content.size.facet.range.include=upper"));
    assertTrue(url.contains("&f.content.size.facet.range.include=outer"));
    assertTrue(url.contains("&f.content.size.facet.range.other=before"));
    assertTrue(url.contains("&f.content.size.facet.range.other=between"));
    assertTrue(url.contains("&f.content.size.facet.range.hardend=true"));

    List<String> filters = new ArrayList<String>();
    filters.add("ex1");

    ranges.clear();
    ranges.add(new RangeParameters("content.size", "0", "1000000", "10000", true, Collections.emptyList(), Collections.emptyList(), "doc", filters));
    params.setRanges(ranges);
    urlBuilder = new StringBuilder();
    client.buildRangeParameters(params, encoder, urlBuilder);
    String url2 = urlBuilder.toString();
    assertTrue(url2.contains("&facet=true"));
    assertTrue(url2.contains("&facet.range="+encoder.encode("{!tag=doc }", "UTF-8")+"content.size"));
    assertTrue(url2.contains("&f.content.size.facet.range.start=0"));
    assertTrue(url2.contains("&f.content.size.facet.range.end=1000000"));
    assertTrue(url2.contains("&f.content.size.facet.range.gap=10000"));
    assertFalse(url2.contains("&f.content.size.facet.range.include=upper"));
    assertFalse(url2.contains("&f.content.size.facet.range.include=outer"));
    assertFalse(url2.contains("&f.content.size.facet.range.other=before"));
    assertTrue(url2.contains("&f.content.size.facet.range.hardend=true"));
    assertTrue(url2.contains("&facet.range={!ex=ex1}content.size"));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:50,代码来源:SolrQueryHTTPClientTest.java


注:本文中的org.alfresco.service.cmr.search.SearchParameters.setSearchTerm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。