protected List<MUCRoomSearchInfo> searchForChatrooms( final SearchParameters params )
    {
        Log.debug( "Searching for rooms based on search parameters." );

        List<MUCRoomSearchInfo> mucs = new ArrayList<>();
        for ( MUCRoomSearchInfo room : mucService.getAllRoomSearchInfo() )
        {
            boolean find = false;

            if ( params.getAll() != null && params.getAll() ) {
                find = true;
            }
            else if ( params.getQ() != null && !params.getQ().isEmpty() )
            {
                final List<String> qs = StringUtils.shellSplit( params.getQ() );

                final String naturalLanguageName = room.getNaturalLanguageName();
                if ( params.isSinname() != null && params.isSinname() && naturalLanguageName != null )
                {
                    if ( qs.stream().allMatch( naturalLanguageName::contains ) )
                    {
                        find = true;
                    }
                }

                final String description = room.getDescription();
                if ( !find && params.isSindescription() != null && params.isSindescription() && description != null )
                {
                    if ( qs.stream().allMatch( description::contains ) )
                    {
                        find = true;
                    }
                }

                final String address = room.getJID().toString();
                if ( !find && params.isSinaddr() != null && params.isSinaddr() && address != null )
                {
                    if ( qs.stream().allMatch( address::contains ) )
                    {
                        find = true;
                    }
                }
            }
            else
            {
                // No search query? Every room matches.
                find = true;
            }

            if ( params.getMinUsers() != null && room.getOccupantsCount() < params.getMinUsers() )
            {
                find = false;
            }

            if ( find && canBeIncludedInResult( room ) )
            {
                mucs.add( room );
            }
        }

        Log.debug( "Search resulted in {} rooms.", mucs.size() );
        return mucs;
    }
Constructs an answer on a IQ stanza that contains a search request. The
answer will be an IQ stanza of type 'result' or 'error'.

@param iq The IQ stanza that is the search request.
@return An answer to the provided request.
xmppserver/src/main/java/org/jivesoftware/openfire/muc/spi/IQExtendedChannelSearchHandler.java