Examples of FacetField


Examples of org.apache.solr.client.solrj.response.FacetField

            solrQuery.addFacetField(FACET);
            solrQuery.setFacetLimit(Integer.MAX_VALUE);
            solrQuery.setFacetMinCount(1);
            solrQuery.setRows(0);
            QueryResponse rsp = service.search(solrQuery);
            FacetField facets = rsp.getFacetField(FACET);

            // for each interests get authority's authors
            List<VisualizationGraphNode> result = null;
            int counter = 0;
            external: for (Count facetElement : facets.getValues())
            {

                counter++;
                log.debug("" + counter + " of " + facets.getValueCount());
                result = new LinkedList<VisualizationGraphNode>();
                try
                {
                    String facetValue = facetElement.getName();
                    String[] splittedFacetValue = facetValue.split("\\|\\|\\|");
                    if (!splittedFacetValue[0].equals("null") && splittedFacetValue[0].equals(splittedFacetValue[1]))
                    {
                        SolrQuery solrQuery2 = new SolrQuery();
                        solrQuery2.setQuery("type:" + connection + " AND "
                                + FACET + ":\"" + ClientUtils.escapeQueryChars(facetValue) + "\" AND a_auth:[* TO *] AND b_auth:[* TO *]");

                        solrQuery2.addFacetField(FACET_AUTHOR);
                        solrQuery2.setFacetMinCount(1);
                        solrQuery2.setFacetLimit(Integer.MAX_VALUE);
                        solrQuery2.setRows(0);

                        QueryResponse rsp2 = service.search(
                                solrQuery2);
                        FacetField relations = rsp2.getFacetField(FACET_AUTHOR);
                        int i = 0;
                        internal: for (Count relation : relations.getValues())
                        {
                            log.debug("" + counter + " works on " + i + " of "
                                    + relations.getValueCount());
                            List<String> values = new LinkedList<String>();
                            values.add(splittedFacetValue[0]);

                            String aaa = relation.getName();
                            String[] split = aaa.split("\\|\\|\\|");
View Full Code Here

Examples of org.apache.solr.client.solrj.response.FacetField

        // solrQuery.addFilterQuery("authors_fauthority:rp00001");
        solrQuery.setFacetLimit(Integer.MAX_VALUE);
        solrQuery.setFacetMinCount(1);
        solrQuery.setRows(0);
        QueryResponse rsp = getService().getSearcher().search(solrQuery);
        FacetField facets = rsp.getFacetField(getFacetFieldQuery());
        System.out.println(facets.getValueCount());
        // for each interests get authority's authors
        List<VisualizationGraphNode> result = null;
        int counter = 0;
        external: for (Count facetElement : facets.getValues())
        {
            counter++;

            log.debug(getConnectionName() + " - " + counter + " of "
                    + facets.getValueCount());
            System.out.println(getConnectionName() + " - " + counter + " of "
                    + facets.getValueCount());
            result = new LinkedList<VisualizationGraphNode>();
            try
            {
                String facetValue = facetElement.getName();
                List<String> relations = getValues(facetValue);

                int i = 0;
                internal: for (String relation : relations)
                {

                    log.debug("" + counter + " works on " + i + " of "
                            + relations.size());
                    System.out.println(getConnectionName() + " - " + counter
                            + " of " + facets.getValueCount() + " works on "
                            + i + " of " + relations.size());
                    String aaa = relation;
                    String[] split = aaa.split("\\|\\|\\|");

                    String a = aaa;
View Full Code Here

Examples of org.apache.solr.client.solrj.response.FacetField

        // solrQuery.addFilterQuery("authors_fauthority:rp00001");
        solrQuery.setFacetLimit(Integer.MAX_VALUE);
        solrQuery.setFacetMinCount(1);
        solrQuery.setRows(0);
        QueryResponse rsp = getService().getSearcher().search(solrQuery);
        FacetField facets = rsp.getFacetField(getFacetFieldQuery());
        System.out.println(facets.getValueCount());
        // for each interests get authority's authors
        List<VisualizationGraphNode> result = null;
        int counter = 0;
        external: for (Count facetElement : facets.getValues())
        {
            counter++;

            log.debug(getConnectionName() + " - " + counter + " of "
                    + facets.getValueCount());
            System.out.println(getConnectionName() + " - " + counter + " of "
                    + facets.getValueCount());
            result = new LinkedList<VisualizationGraphNode>();
            try
            {

                String facetValue = facetElement.getName();

                solrQuery = new SolrQuery();
                String query = (useJoin()?getJoin():"") + getFacetFieldQuery() + ":\"" + ClientUtils.escapeQueryChars(facetValue) + "\"";
                solrQuery.setQuery(query);
                solrQuery.addFacetField(getFacet(facetValue));
                solrQuery.setFacetMinCount(1);
                solrQuery.setFacetLimit(getFacetLimit());
                solrQuery.setRows(0);

                rsp = getService().getSearcher().search(solrQuery);
                FacetField relations = rsp.getFacetField(getFacet(facetValue));
                int i = 0;
                internal: for (Count relation : relations.getValues())
                {

                    log.debug("" + counter + " works on " + i + " of "
                            + relations.getValueCount());
                    System.out.println(getConnectionName() + " - " + counter
                            + " of " + facets.getValueCount() + " works on "
                            + i + " of " + relations.getValueCount());
                    String aaa = relation.getName();
                    String[] split = aaa.split("\\|\\|\\|");

                    String a = aaa;
                    String a_authority = null;
                    String a_dept = null;
                    String a_displayValue = "";

                    if (split.length > 1)
                    {
                                               
                        String[] splitAuthority = split[1].split(splitterAuthority);
                       
                        a_displayValue = splitAuthority[0];
                        if (splitAuthority.length > 1)
                        {
                            a_authority = splitAuthority[1];
                            // a_dept = ResearcherPageUtils
                            // .getDepartment(a_authority);
                            a_dept = getDepartmentFromSOLR(a_authority);
                        }
                       
                    }

                    internalprivate: for (int j = i; j < relations.getValues()
                            .size(); j++)
                    {
                        List<String> values = new LinkedList<String>();
                        values.add(facetValue);

                        String bbb = relations.getValues().get(j).getName();
                        split = bbb.split("\\|\\|\\|");

                        String b = bbb;
                        String b_authority = null;
                        String b_dept = null;
View Full Code Here

Examples of org.apache.solr.client.solrj.response.FacetField

        solrQuery.setFacetMinCount(1);
        solrQuery.setRows(0);

        QueryResponse rsp = service.search(solrQuery);

        FacetField facets = rsp.getFacetField(FACET_SEARCH);

        JsGraph rsGraph = null;
        String src = null;
        if (authority != null && !authority.isEmpty())
        {
            src = authority;
            rsGraph = new JsGraph();
            rsGraph.setId(authority);
            rsGraph.setName(name);
            JsGraphNodeData dataNode = new JsGraphNodeData();
            dataNode.setColor(getNodeCustomColor());
            dataNode.setType(getType());
            dataNode.setModeStyle("fill");
            rsGraph.setData(dataNode);

        }
        else
        {
            src = name;
            rsGraph = new JsGraph();
            rsGraph.setId(name);
            rsGraph.setName(name);
            JsGraphNodeData dataNodeLeaf = new JsGraphNodeData();
            dataNodeLeaf.setColor(getNodeLeafCustomColor());           
            dataNodeLeaf.setType(getType());
            dataNodeLeaf.setModeStyle("stroke");
            rsGraph.setData(dataNodeLeaf);

        }
        if (rsGraph != null)
        {
            if (facets != null && facets.getValueCount() > 0)
            {
                for (Count facet : facets.getValues())
                {
                    if (facet.getCount() > 0)
                    {

                        String node2 = (String) facet.getName();
View Full Code Here

Examples of org.apache.solr.client.solrj.response.FacetField

        solrQuery.addFacetField(FACET_METRICS);
        solrQuery.setFacetLimit(Integer.MAX_VALUE);
        solrQuery.setFacetMinCount(1);
        solrQuery.setRows(0);
        QueryResponse rsp = getService().search(solrQuery);
        FacetField facets = rsp.getFacetField(FACET_METRICS);

        // for each interests get authority's authors
        List<ResearcherPage> result = new LinkedList<ResearcherPage>();
        int counter = 0;
        external: for (Count facetElement : facets.getValues())
        {
            counter++;
            log.debug("" + counter + " of " + facets.getValueCount());
            ResearcherPage researcher = null;
            try
            {
                String facetValue = facetElement.getName();

                Integer realPersistentIdentifier = ResearcherPageUtils
                        .getRealPersistentIdentifier(facetValue, ResearcherPage.class);
                researcher = applicationService
                        .get(ResearcherPage.class, realPersistentIdentifier);
                //researcher.getDynamicField().setAnagraficaLazy(applicationService.getAnagraficaByRP(realPersistentIdentifier));
           
                solrQuery = new SolrQuery();
                solrQuery.setQuery("type:" + getType() + " AND entity:" + ConstantNetwork.ENTITY_RP + " AND " + FACET_METRICS + ":\"" + facetValue + "\"");
                solrQuery.addFacetField(FACET_SEARCH);
                solrQuery.setFacetMinCount(1);
                solrQuery.setFacetLimit(Integer.MAX_VALUE);
                solrQuery.setRows(0);

                rsp = getService().search(solrQuery);
                FacetField relations = rsp.getFacetField(FACET_SEARCH);
                int i = 0;
                int nConnections = 0;
                int maxStrength = 0;
                int sumStrength = 0;
                List<Long> quadraticVarianceArrays = new ArrayList<Long>();
                nConnections = Integer.valueOf(relations
                        .getValueCount() - 1);
                internal: for (Count relation : relations.getValues())
                {

                    log.debug("" + counter + " works on " + i + " of "
                            + relations.getValueCount());

                    if (i == 0)
                    {                    
                        i++;
                        continue internal;
View Full Code Here

Examples of org.apache.solr.client.solrj.response.FacetField

    QueryResponse rsp = server.query( query );
    assertEquals( docs.size(), rsp.getResults().getNumFound() );
   
    List<FacetField> facets = rsp.getFacetFields();
    assertEquals( 1, facets.size() );
    FacetField ff = facets.get( 0 );
    assertEquals( "features", ff.getName() );
    // System.out.println( "111: "+ff.getValues() );
    // check all counts
    assertEquals( "[two (5), three (3), five (2), four (2)]", ff.getValues().toString() );
   
    // should be the same facets with minCount=0
    query.setFilterQueries( "features:two" );
    rsp = server.query( query );
    ff = rsp.getFacetField( "features" );
    assertEquals( "[two (5), four (2), five (1), three (1)]", ff.getValues().toString() );
   
    // with minCount > 3
    query.setFacetMinCount( 4 );
    rsp = server.query( query );
    ff = rsp.getFacetField( "features" );
    assertEquals( "[two (5)]", ff.getValues().toString() );

    // with minCount > 3
    query.setFacetMinCount( -1 );
    rsp = server.query( query );
    ff = rsp.getFacetField( "features" );
View Full Code Here

Examples of org.apache.solr.client.solrj.response.FacetField

    QueryResponse rsp = server.query( query );
    assertEquals( docs.size(), rsp.getResults().getNumFound() );
   
    List<FacetField> facets = rsp.getFacetFields();
    assertEquals( 1, facets.size() );
    FacetField ff = facets.get( 0 );
    assertEquals( "features", ff.getName() );
    System.out.println( "111: "+ff.getValues() );
    // check all counts
    assertEquals( "[two (5), three (3), five (2), four (2)]", ff.getValues().toString() );
   
    // should be the same facets with minCount=0
    query.setFilterQueries( "features:two" );
    rsp = server.query( query );
    ff = rsp.getFacetField( "features" );
    assertEquals( "[two (5), four (2), five (1), three (1)]", ff.getValues().toString() );
   
    // with minCount > 3
    query.setFacetMinCount( 4 );
    rsp = server.query( query );
    ff = rsp.getFacetField( "features" );
    assertEquals( "[two (5)]", ff.getValues().toString() );

    // with minCount > 3
    query.setFacetMinCount( -1 );
    rsp = server.query( query );
    ff = rsp.getFacetField( "features" );
   
    System.out.println( rsp.getResults().getNumFound() + " :::: 444: "+ff.getValues() );
  }
View Full Code Here

Examples of org.apache.solr.client.solrj.response.FacetField

    QueryResponse rsp = server.query( query );
    assertEquals( docs.size(), rsp.getResults().getNumFound() );
   
    List<FacetField> facets = rsp.getFacetFields();
    assertEquals( 1, facets.size() );
    FacetField ff = facets.get( 0 );
    assertEquals( "features", ff.getName() );
    System.out.println( "111: "+ff.getValues() );
    // check all counts
    assertEquals( "[two (5), three (3), five (2), four (2)]", ff.getValues().toString() );
   
    // should be the same facets with minCount=0
    query.setFilterQueries( "features:two" );
    rsp = server.query( query );
    ff = rsp.getFacetField( "features" );
    assertEquals( "[two (5), four (2), five (1), three (1)]", ff.getValues().toString() );
   
    // with minCount > 3
    query.setFacetMinCount( 4 );
    rsp = server.query( query );
    ff = rsp.getFacetField( "features" );
    assertEquals( "[two (5)]", ff.getValues().toString() );

    // with minCount > 3
    query.setFacetMinCount( -1 );
    rsp = server.query( query );
    ff = rsp.getFacetField( "features" );
   
    System.out.println( rsp.getResults().getNumFound() + " :::: 444: "+ff.getValues() );
  }
View Full Code Here

Examples of org.apache.solr.client.solrj.response.FacetField

            for (Map.Entry<String, NamedList<Number>> facet : ff) {
                String key = StringUtils.substringBeforeLast(facet.getKey(),
                        SimpleJahiaJcrFacets.PROPNAME_INDEX_SEPARATOR);
                String fieldInIndex = StringUtils.substringAfterLast(facet.getKey(),
                        SimpleJahiaJcrFacets.PROPNAME_INDEX_SEPARATOR);
                FacetField f = new FacetField(key);
                for (Map.Entry<String, Number> entry : facet.getValue()) {
                    f.add(entry.getKey(), entry.getValue().longValue());
                    f.getValues().get(f.getValueCount() - 1).setFilterQuery(
                            ClientUtils.escapeQueryChars(fieldInIndex) + ":"
                                    + ClientUtils.escapeQueryChars(entry.getKey()));
                }

                _facetFields.add(f);
                FacetField nl = f.getLimitingFields(minsize);
                if (nl.getValueCount() > 0) {
                    _limitingFacets.add(nl);
                }
            }
        }

        // Parse date facets
        NamedList<NamedList<Object>> df = (NamedList<NamedList<Object>>) info.get("facet_dates");
        if (df != null) {
            // System.out.println(df);
            _facetDates = new ArrayList<FacetField>(df.size());
            for (Map.Entry<String, NamedList<Object>> facet : df) {
                // System.out.println("Key: " + facet.getKey() + " Value: " + facet.getValue());
                NamedList<Object> values = facet.getValue();
                String gap = (String) values.get("gap");
                Date end = (Date) values.get("end");
                FacetField f = new FacetField(StringUtils.substringBeforeLast(facet.getKey(),
                        SimpleJahiaJcrFacets.PROPNAME_INDEX_SEPARATOR), gap, end);

                for (Map.Entry<String, Object> entry : values) {
                    try {
                        String key = StringUtils.substringBeforeLast(entry.getKey(),
                                SimpleJahiaJcrFacets.PROPNAME_INDEX_SEPARATOR);
                        String query = StringUtils.substringAfterLast(entry.getKey(),
                                SimpleJahiaJcrFacets.PROPNAME_INDEX_SEPARATOR);
                        f.add(key, Long.parseLong(entry.getValue().toString()));
                        if (!StringUtils.isEmpty(query)) {
                            String rangePrefix = null;
                            if (query.contains(RANGEFROM_EXCLUSIVE_PREFIX)) {
                                rangePrefix = RANGEFROM_EXCLUSIVE_PREFIX;
                            } else if (query.contains(RANGEFROM_INCLUSIVE_PREFIX)) {
                                rangePrefix = RANGEFROM_INCLUSIVE_PREFIX;
                            }
                            if (!StringUtils.isEmpty(rangePrefix)) {
                                f.getValues().get(f.getValueCount() - 1).setFilterQuery(
                                        ClientUtils.escapeQueryChars(StringUtils.substringBefore(
                                                query, rangePrefix))
                                                + rangePrefix
                                                + StringUtils.substringAfter(query, rangePrefix));
                            }
View Full Code Here

Examples of org.apache.solr.client.solrj.response.FacetField

    public void testSimpleFacets() throws Exception {

        JCRSessionWrapper session = JCRSessionFactory.getInstance().getCurrentUserSession(Constants.EDIT_WORKSPACE,
                LanguageCodeConverters.languageCodeToLocale(DEFAULT_LANGUAGE));

        FacetField field;
        QueryResultWrapper res;

        // check facets
        res = doQuery(session, "eventsType", "rep:facet(facet.mincount=1)");
        checkResultSize(res, 27);
        field = res.getFacetField("eventsType");
        assertNotNull("Facet field is null",field);
        assertNotNull("Facet values are null",field.getValues());
        assertEquals("Query did not return correct number of facets", 6, field.getValues().size());
        Iterator<FacetField.Count> counts = field.getValues().iterator();

        checkFacet(counts.next(), SHOW, 7);
        checkFacet(counts.next(), PRESS_CONFERENCE, 6);
        checkFacet(counts.next(), CONFERENCE, 5);
        checkFacet(counts.next(), ROAD_SHOW, 4);
        checkFacet(counts.next(), CONSUMER_SHOW, 3);
        checkFacet(counts.next(), MEETING, 2);

        for (FacetField.Count count : field.getValues()) {
            QueryResultWrapper resCheck = doFilteredQuery(session, "eventsType", count.getName());
            checkResultSize(resCheck, (int) count.getCount());
        }
       
        for (FacetField.Count count : field.getValues()) {
            QueryResultWrapper resCheck = doQuery(session, "rep:filter(eventsType)", count.getAsFilterQuery());
            checkResultSize(resCheck, (int) count.getCount());
        }       

        // test facet options : prefix
        res = doQuery(session, "eventsType", "rep:facet(facet.mincount=1&prefix=c)");
        field = res.getFacetField("eventsType");
        assertNotNull("Facet field is null",field);
        assertNotNull("Facet values are null",field.getValues());
        assertEquals("Query did not return correct number of facet values", 2, field.getValues().size());
        counts = field.getValues().iterator();

        checkFacet(counts.next(), CONFERENCE, 5);
        checkFacet(counts.next(), CONSUMER_SHOW, 3);
       
        for (FacetField.Count count : field.getValues()) {
            QueryResultWrapper resCheck = doQuery(session, "rep:filter(eventsType)", count.getAsFilterQuery());
            checkResultSize(resCheck, (int) count.getCount());
        }               

        // test facet options : sort=false  - lexicographic order
        res = doQuery(session, "eventsType", "rep:facet(facet.mincount=1&sort=false)");
        field = res.getFacetField("eventsType");
        assertNotNull("Facet field is null",field);
        assertNotNull("Facet values are null",field.getValues());
        assertEquals("Query did not return correct number of facet value", 6, field.getValues().size());
        counts = field.getValues().iterator();

        checkFacet(counts.next(), CONFERENCE, 5);
        checkFacet(counts.next(), CONSUMER_SHOW, 3);
        checkFacet(counts.next(), MEETING, 2);
        checkFacet(counts.next(), PRESS_CONFERENCE, 6);
        checkFacet(counts.next(), ROAD_SHOW, 4);
        checkFacet(counts.next(), SHOW, 7);
       
        for (FacetField.Count count : field.getValues()) {
            QueryResultWrapper resCheck = doQuery(session, "rep:filter(eventsType)", count.getAsFilterQuery());
            checkResultSize(resCheck, (int) count.getCount());
        }               

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.