mirror of https://github.com/zlatinb/muwire
canonize search terms
parent
d2533cc4d6
commit
de856cd085
|
@ -10,4 +10,6 @@ class Constants {
|
||||||
public static final int MAX_HEADERS = 16
|
public static final int MAX_HEADERS = 16
|
||||||
|
|
||||||
public static final float DOWNLOAD_SEQUENTIAL_RATIO = 0.8f
|
public static final float DOWNLOAD_SEQUENTIAL_RATIO = 0.8f
|
||||||
|
|
||||||
|
public static final String SPLIT_PATTERN = "[\\.,_-]"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muwire.core.search
|
package com.muwire.core.search
|
||||||
|
|
||||||
|
import com.muwire.core.Constants
|
||||||
|
|
||||||
class SearchIndex {
|
class SearchIndex {
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ class SearchIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String[] split(String source) {
|
private static String[] split(String source) {
|
||||||
source = source.replaceAll("[\\.,_-]", " ")
|
source = source.replaceAll(Constants.SPLIT_PATTERN, " ").toLowerCase()
|
||||||
source.split(" ")
|
source.split(" ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import griffon.metadata.ArtifactProviderFor
|
||||||
import javax.annotation.Nonnull
|
import javax.annotation.Nonnull
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
import com.muwire.core.Constants
|
||||||
import com.muwire.core.Core
|
import com.muwire.core.Core
|
||||||
import com.muwire.core.download.DownloadStartedEvent
|
import com.muwire.core.download.DownloadStartedEvent
|
||||||
import com.muwire.core.download.UIDownloadEvent
|
import com.muwire.core.download.UIDownloadEvent
|
||||||
|
@ -39,7 +40,9 @@ class MainFrameController {
|
||||||
def group = mvcGroup.createMVCGroup("SearchTab", uuid.toString(), params)
|
def group = mvcGroup.createMVCGroup("SearchTab", uuid.toString(), params)
|
||||||
model.results[uuid.toString()] = group
|
model.results[uuid.toString()] = group
|
||||||
|
|
||||||
def searchEvent = new SearchEvent(searchTerms : [search], uuid : uuid)
|
// this can be improved a lot
|
||||||
|
def terms = search.toLowerCase().trim().split(Constants.SPLIT_PATTERN)
|
||||||
|
def searchEvent = new SearchEvent(searchTerms : terms, uuid : uuid)
|
||||||
core.eventBus.publish(new QueryEvent(searchEvent : searchEvent, firstHop : true,
|
core.eventBus.publish(new QueryEvent(searchEvent : searchEvent, firstHop : true,
|
||||||
replyTo: core.me.destination, receivedOn: core.me.destination))
|
replyTo: core.me.destination, receivedOn: core.me.destination))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue